Writing Latex articles with Vim

Vim is a text editor, part of the standard suite on a UNIX system.

This is a short post which is a store of some Vim keystrokes that I am progressively discovering, and which are worth sharing for anyone interested.

The main point is that with Vim you learn a new method of moving around a text file, so it is a bit like learning new paradigms for a foreign language if you like.

  1. Don’t move with the arrows, move by words or by searching.
    This means that for scanning through text you might do:

    1. Move forwards and back quickly with W, B and E (move by words, without recognizing punctuation),
    2. Get closer by releasing the shift and using w, b or e in the final stages to home in.

    And to move through larger distances use a quick search:

    1. hit / and type a bit of text to search forward, with n and N to move forward and back along those points,
    2. hit ? and type text to search backward, then use n and N likewise.
  2. Copy text you just typed for a paste later:
    1. Enter the text, then ESC and v to enter VISUAL mode,
    2. use ‘[ (moves to the point of where text was last changed),
    3. yank it with y.

For example, if I need to add something like ‘_{\text{N}}’ to a few ‘\sigma’ in my article I do this:

  1. find a ‘\sigma’ with /\\sigma,
  2. move to the end with e, and then append with a,
  3. type ‘_{\text{N}}’,
  4. ESC out and v into VISUAL mode,
  5. ‘[ and y to copy that text,
  6. now an n will take me to the next instance of ‘\sigma’
  7. and a quick e then p will paste the text where I want it.

Nice! In short, Vim seems to be a good fit for all of the usual text manipulations I do in a Latex article.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s