Vim Cheatsheet

This Vim Cheatsheet is compatible with my ~/.vimrc

This is an ongoing effort to document motions and commands available from my ~/.vimrc

Leader

Leader is mapped to ,.

Comments

Provided by tomtom/tcomment_vim, it allows to easily comment/uncomments code.

  • gcc Toggles comment for the current line

In Visual mode

  • gc Toggle comments for the current selection

Surroundings (parentheses, brackets, quotes and more)

tpope/vim-surround takes care of dealing with parentheses, brackets, quotes, XML tages and more.

"Hello World"

  • cs"’'Hello World'
  • cs’<q><q>Hello World</q>
  • cst""Hello World"
  • ds"Hello World
  • ysiw<em> on Hello → <em>Hello</em> World
  • Visually select line, S<p class=“important”>
1<p class="important">
2<em>Hello</em> Worls
3</p>

Tabularize

Make lists of assignments and such more readable. This feature is auto enabled while typing for Cucumber/Gherkin style example (using |).

1Background:
2    Given I have the following recipes:
3    | name             | rating |
4    | Spaghetti        | 4      |
5    | Lasgna Bolognese | 5      |

You can also manually invoke Tabularize:

1a = 1
2b = 42
3test = 512

Visually select, then ,a=:

1a    = 1
2b    = 42
3test = 512

Similarly, using ,a:

1a: 1,
2b: 42,
3test: 512

results in:

1a:     1,
2b:     42,
3test:  512