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).
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).
I’d strongly recommend to keep working with swap files (in case Vim crashes). You can set the directory where the swap files are stored, so they don’t clutter your normal directories: set swapfile set dir=~/tmp See also :help swap-file
Why not use tabs (introduced in Vim 7)? You can switch between tabs with :tabn and :tabp, With :tabe <filepath> you can add a new tab; and with a regular :q or :wq you close a tab. If you map :tabn and :tabp to your F7/F8 keys you can easily switch between files. If there … Read more
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
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
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.
Although I would not recommend changing the default cursor mechanics, one way of achieving the behavior in question is to use the following Insert-mode mapping. :inoremap <silent> <Esc> <Esc>`^ Here the Esc key is overloaded in Insert mode to additionally run the `^ command which moves the cursor to the position where it had been the … Read more
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
The problem There are two ways for a terminal emulator to send an Alt key (usually called a Meta key as actual terminals didn’t have Alt). It can either send 8 bit characters and set the high bit when Alt is used, or it can use escape sequences, sending Alt-a as <Esc>a. Vim expects to … Read more
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