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.

Indenting in VIM with all the files in Folder

Much simpler than scripting vim from the bash command line is to use vimscript from inside of vim (or perhaps a much simpler one-liner for scripting vim from the command line). I personally prefer using the arg list for all multi-file manipulation. For example: :args ~/src/myproject/**/*.ttl | argdo execute “normal gg=G” | update args sets … Read more

Vim auto-generate ctags

au BufWritePost *.c,*.cpp,*.h silent! !ctags -R & The downside is that you won’t have a useful tags file until it completes. As long as you’re on a *nix system it should be ok to do multiple writes before the previous ctags has completed, but you should test that. On a Windows system it won’t put … Read more