Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment with tabs #613

Closed
timokau opened this issue Oct 27, 2016 · 6 comments
Closed

Alignment with tabs #613

timokau opened this issue Oct 27, 2016 · 6 comments

Comments

@timokau
Copy link

timokau commented Oct 27, 2016

Issue

When using tabs (noexpandtab), vimtex adds additional alignment after an ampersand when inserting opening braces. For example:

\begin{align*}
    aaaaaaa &=
            &
\end{align*}

Aligns to this after Inserting {:

\begin{align*}
    aaaaaaa &=
               &{
\end{align*}

How often this happens depends on the number of characters until the ampersand in the first line. For example, here there are 7 as, 1 whitespace and the &. That results in one additional indent when a { is typed (more {s won't do anything). Any aditional character will result in one more ident, for example using 8 as:

\begin{align*}
    aaaaaaaa &=
                   &{{
\end{align*}

Expected

I'd prefer to use tabs for indentation, spaces for alignment so ideally it should format to (TTTT = 1 Tab, _ = 1 Space)

\begin{align*}
TTTTaaaaaaaa &=
TTTT________&{{
\end{align*}

But that is probably hard to implement, so no alignment at all would also be good. I don't want to disable it using vimtex-indent, because I'd like to keep the normal indentation.

Reproduce

Using this vimrc with vim-plug (technically set list isn't needed, but it helps):

set nocompatible

" Load Vimtex
let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'

filetype plugin indent on
syntax enable
set list

And this tex file:

\begin{align*}
    aaaaaaa &=
            &
\end{align*}

Type { after the second ampersand.

@lervag
Copy link
Owner

lervag commented Oct 27, 2016

Ok, so you would be happy if I added an option to disable the alignment of ampersands? That is a trivial update. I could add g:vimtex_indent_align_on_ampersand with default value 1 that you could disable by setting to 0.

Mixing tabs and spaces is something I don't want to touch. It seems hard! But adding an option is something I can definately consider.

@timokau
Copy link
Author

timokau commented Oct 27, 2016

Yes. Often I don't want the alignment anyways because it takes away too much screen space.

You probably can't please everyone with tabs and spaces anyways, but this bit of configurability would help a lot.

@heiderich
Copy link

I would also welcome this.

@lervag
Copy link
Owner

lervag commented Dec 29, 2016

Ok, I just read this once more. I think the problem here is that I personally use set expandtab (among other things). In this case, everything works pretty much as expected. However, for some reason, the indentation is screwed when tabs and spaces are mixed.

I'll add an option to disable alignment on ampersands in not too long.

@lervag lervag closed this as completed in 404061f Dec 30, 2016
@timokau
Copy link
Author

timokau commented Dec 30, 2016

Thanks, works for me!

@lervag
Copy link
Owner

lervag commented Jan 1, 2017

Great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants