I am using Vim to edit my tex file and I am relatively new to LaTeX. One thing that I don't understand is why tex wants you to write incredibly long lines in your tex file? For instance, each line becomes a new paragraph so if you have along paragraph you can have a line in your text file that is miles long. Currently this is driving me crazy because if I press 'j' or 'k' to move up and down lines I move lines at a time instead of paragraphs at a time.

While messing with this I just feel like "This can't be what I'm supposed to be doing." Does anyone else use an editor like vi/vim to edit their tex files, and if so, how do you navigate? If you are editing your .tex file full screen (to get rid of distractions), how do you prevent full monitor word garbage due to incredibly long lines?

I really like the TeX philosophy of separating content from design, but I feel like I am going to make myself go cross-eyed editing these .tex files.

  • 3
    TeX ignores single line breaks. Format your file however you want! Mar 17 '14 at 14:37
  • 2
    Only blank lines enforce a new paragraph. You can still use single linebreaks to structure your source. Mar 17 '14 at 14:38
  • 3
    @IanThompson better to say it treats single linebreaks like a space Mar 17 '14 at 14:43
  • 1
    @HenriMenke The "one sentence per line" (the third way) is particularly nice if you keep your .tex files under version control, since it makes diff-ing much easier. Mar 17 '14 at 15:20
  • 1
    In Vim gq} is your friend to reflow the current paragraph in a TeX source file (provided you have set textwidth to something sensible.
    – Thruston
    Mar 18 '14 at 10:27

You can press return at the end, but in VIM you would typically "reformat" or "rewrap" a paragraph after and during writing. Typical commands to do so are:

gq (see :help gq)
gw (like gq but puts the cursor back where it started
:set textwidth = 70 

:set textwidth is something people use for automatic wrapping, and sometimes it appears in their vimrc or plugin. I personally don't like it, and find that just rewrapping lines is much faster.

Once you get used to wrapping it becomes second nature while writing. I find that restyling the tex code is another way to find mistakes in the content or structure that I would not otherwise see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.