Traversing text in Insert mode

While it may make sense that you should be able to use the h j k l keys to traverse the editor in insert mode, but that is actually not the way Vim is intended to be used! There are many commands that Vim provides to make editing faster and easier. The right way is … Read more

Why is \r a newline for Vim?

From http://vim.wikia.com/wiki/Search_and_replace : When Searching … \n is newline, \r is CR (carriage return = Ctrl-M = ^M) When Replacing … \r is newline, \n is a null byte (0x00).

What is the in a .vimrc file?

The <Leader> key is mapped to \ by default. So if you have a map of <Leader>t, you can execute it by default with \+t. For more detail or re-assigning it using the mapleader variable, see :help leader To define a mapping which uses the “mapleader” variable, the special string “<Leader>” can be used. It … Read more

Convert ^M (Windows) line breaks to normal line breaks

Command :%s/<Ctrl-V><Ctrl-M>/\r/g Where <Ctrl-V><Ctrl-M> means type Ctrl+V then Ctrl+M. Explanation :%s substitute, % = all lines <Ctrl-V><Ctrl-M> ^M characters (the Ctrl-V is a Vim way of writing the Ctrl ^ character and Ctrl-M writes the M after the regular expression, resulting to ^M special character) /\r/ with new line (\r) g And do it globally … Read more

Using vim’s f command over multiple lines

Isn’t that what “https://stackoverflow.com/” does? If you’re looking for the next “x” then do /x while in command mode. Then you can hit “n” to advance to the next x, and then the next x, etc. There are lots of vim cheat sheets out there with all kinds of tips.