The best practice mentioned in the title is the one suggested by Uri:
When writing paragraphs, start each sentence at the beginning of a line, and if it spills over, each subsequent line is tabbed.
I use gVim with Vim-LaTeX, which comes with an indent/tex.vim
file, to edit LaTeX files. The way I currently implement the practice mentioned above is as follows:
:set textwidth=79
to automatically break lines before they become too long.Occasionally, that last step will make one or more spillovers go over the maximum line width. In this case, I
As you can imagine, this can become tedious. Isn't there a more efficient way to achieve the same result? Ultimately, I want to be able to write the sentences without worrying about their format, and then use gqap, or gqip, to automatically produce the result that I currently produce manually.
To do that, I suspect that I will need to write a formatexpr
of my own, but I'm not sure how to proceed. I have found a number of plugins, Latex Text Formatter and Text (Especially LaTeX) Formatter, and a tip, but none of them seem to suit my needs, and I'm not sure how to modify them to do so.
Vim is undoubtedly one of the best editors ever made. LaTeX is an extremely powerful, intelligent typesetter. Vim-LaTeX aims at bringing together the best of both these worlds. We attempt to provide a comprehensive set of tools to view, edit and compile LaTeX documents without needing to ever quit Vim.
I may well be oversimplifying the problem, but does this mapping do what you want?
nnoremap \z (j>>gq)
So pressing \z in normal mode will do the following: From the cursor position, jump to the start of the sentence. Then go to the next line and indent it. Then reformat from this line to the end of the sentence. Reformatting sentence-wise is the way to go, rather than reformatting each line individually, as your method seems to do.
Of course you can use an insert-mode mapping if you prefer, or even try redefining the behaviour of the Enter key to do this automatically (although I don't know if this will have unintended consequences...).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With