vim tricks – different types of insert, repeat

To repeat your last operation type ‘.’ in command mode.

Here are some different ways to insert

A – append text to end of line
I – insert text at beginning of line
o – open blank line below cursor
O – open blank line above cursur
s – delete char at cursor and sub text
S – Delete line and sub text
R – overstrike existing chars with new chars

To think, I’ve survived with only i, a, r, and I think I’ve used R before to this day.

One thing that’s interesting.  I wonder how many people think they know how to use their text editor and don’t.  I know I thought I knew vim pretty good until I started to learn how to use it.

I should mention

These can be preceded with numbers. For example,

5i*- [esc] will insert

vim trick – restoring something you delete

If you delete, like say, 3 lines fast.


and want to restore the 1st thing deleted only (not the other 2) you can with the following command:


pretty slick.  I’m not sure I’ll ever be enough of a power user to remember it.

vim tricks

Here are some tricks in everyone’s favorite editor, vim.

In command mode

To indent a file:


To indent between matching brackets (go over the bracket)


To copy to the X clipboard or Windows clipboard using the keyboard (as opposed to the vim clipboard)
I normally highlight the text using ‘v’ to go into visual mode and then

To copy to the X clipboard, I’ve found it can be easier than the crossed out jazz to set your terminal short cuts . I tend to use CTRL+SHIFT+C for copy, CTRL+SHIFT+V for paste. This also has the advantage of working regardless of editor.
These can be handy!