On Tuesday, March 3, 2015 at 10:37:12 AM UTC-6, ZyX wrote:
> 2015-03-03 17:17 GMT+03:00 at <[email protected]>:
> I found the following code on a stackexchange post:
> http://tex.stackexchange.com/questions/1548/intelligent-paragraph-reflowing-in-vim
>
>
>
> The code is for environment-aware formatting in LaTeX.
>
>
>
> It's not longer working quite the way I want it---I think it is interacting
> with one of my other plugins that has been updated---so I'd like to try to
> modify it. However I don't have a great knowledge of the Vim scripting
> language, so I don't really understand what's going on in the code. Could
> someone explain it to me?
>
>
>
> You better explain how it is interacting. Based on the kind of interaction it
> may appear that you need to know only a few lines. The code below simply
> selects lines between some lines like `\start`…` \start` and tells Vim to
> reformat them.
>
>
> Basically you need to know `:h range`, `:h gq` and, if you still don’t
> understand other code, `:h :{command}` where `:{command}` is a lowercase
> letter sequence at the start of the line with colon prepended.
>
>
>
> Alternatively/additionally, if you have a good solution for formatting in
> LaTeX, please share!
>
>
>
> Here's the code. It's also on the Stackexchange post in case the formatting
> gets messed up:
>
>
>
> " Reformat lines (getting the spacing correct) {{{
>
> fun! TeX_fmt()
>
> if (getline(".") != "")
>
> let save_cursor = getpos(".")
>
> let op_wrapscan = &wrapscan
>
> set nowrapscan
>
> let par_begin =
> '^\(%D\)\=\s*\($\|\\start\|\\stop\|\\Start\|\\Stop\|\\\(sub\)*section\>\|\\item\>\|\\NC\>\|\\blank\>\|\\noindent\>\)'
>
> let par_end =
> '^\(%D\)\=\s*\($\|\\start\|\\stop\|\\Start\|\\Stop\|\\place\|\\\(sub\)*section\>\|\\item\>\|\\NC\>\|\\blank\>\)'
>
> try
>
> exe '?'.par_begin.'?+'
>
> catch /E384/
>
> 1
>
> endtry
>
> norm V
>
> try
>
> exe '/'.par_end.'/-'
>
> catch /E385/
>
> $
>
> endtry
>
> norm gq
>
> let &wrapscan = op_wrapscan
>
> call setpos('.', save_cursor)
>
> endif
>
> endfun
>
>
>
> nmap Q :call TeX_fmt()<CR>
>
>
>
> --
>
> --
>
> You received this message from the "vim_use" maillist.
>
> Do not top-post! Type your reply below the text you are replying to.
>
> For more information, visit http://www.vim.org/maillist.php
>
>
>
> ---
>
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
> For more options, visit https://groups.google.com/d/optout.
First, let me mention one thing I forgot to add---I modified the script
according to the Stackexchange comment by "wmnorth" (see third comment down on
that post)
The specific behavior is difficult to pin/down replicate. But the general
problem is that I will have a block of text that looks like:
\begin{proof}
blah blah blah
blah blah $a = b$
blah blah
\end{proof}
but typically has many more lines than that.
When I call this script in normal mode with the cursor on the interior part of
the begin/end proof block, sometimes the indenting will be destroyed. Again,
it's not always, and I haven't been able to isolate a minimal working example.
(It also does not only happen with "proof" but also happens with other
begin/end pairs.)
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.