#38 Sometimes doesn't unindent with a \end

open-works-for-me
nobody
None
5
2012-05-25
2012-05-25
Anonymous
No

For a file like
\begin{test}
foo\end{test}
bar
After the indent, it should be like
\begin{test}
foo\end{test}
bar
But when I use the automatic indent, it becomes
\begin{ŧest}
foo\end{test}
bar
After some experiment, I found out that \end were ignored every time there is other things that spaces and tabs before them on the line.
Looking at the source code of the file indent/tex.vim, I found that it was about the line 180 that reads
if cline =~ '^\s*\\end' && cline !~ g:tex_noindent_env
I changed it on my computer to
if cline =~ '^\s*\\end' && cline !~ g:tex_noindent_env
And it fixed the bug

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-05-25

    Ok, my fix doesn't work, I know understand why the '^\s*' was there but I have another fix.
    I watch the previous line. If it contains a '\\end' and no '\\end' starting a line, it unindent.
    here is the change
    " Subtract a 'shiftwidth' when an environment ends
    if cline =~ '^\s*\\end' && cline !~ 'verbatim'
    \&& cline !~ 'document'
    \&& cline !~ 'comment'

    if g:tex_indent_items == 1
    " Remove another sw for item-environments
    if cline =~ 'itemize\|description\|enumerate\|thebibliography'
    let ind = ind - &sw
    endif
    endif

    let ind = ind - &sw
    endif

    +" Subtract a 'shiftwidth' when an environment ended
    +" the previous line but the shifwidth wasn't
    +" applied because it didn't begin the line
    +if line =~ '\\end' && line !~ '^\s*\\end'
    + \&& line !~ 'verbatim'
    + \&& line !~ 'document'
    + \&& line !~ 'comment'
    +
    + if g:tex_indent_items == 1
    + " Remove another sw for item-environments
    + if line =~ 'itemize\|description\|enumerate\|thebibliography'
    + let ind = ind - &sw
    + endif
    + endif
    +
    + let ind = ind - &sw
    +endif

    " Special treatment for 'item'
    " ----------------------------

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-05-25
    • status: open --> open-works-for-me
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks