vim
Vim delete blank lines
:g/^$/d :g will execute a command on lines which match a regex. The regex is ‘blank line’ and the command is :d (delete)
How to move screen without moving cursor in Vim?
zz – move current line to the middle of the screen (Careful with zz, if you happen to have Caps Lock on accidentally, you will save and exit vim!) zt – move current line to the top of the screen zb – move current line to the bottom of the screen
Differences between Emacs and Vim
(the text below is my opinion, it should not be taken as fact or an insult) With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note-taking, organization, games, programming, shell access, file … Read more
Convert DOS line endings to Linux line endings in Vim
dos2unix is a commandline utility that will do this, or :%s/^M//g will if you use Ctrl–v Ctrl–m to input the ^M, or you can :set ff=unix and Vim will do it for you. There is documentation on the fileformat setting, and the Vim wiki has a comprehensive page on line ending conversions. Alternately, if you … Read more
What are the dark corners of Vim your mom never told you about? [closed]
Might not be one that 99% of Vim users don’t know about, but it’s something I use daily and that any Linux+Vim poweruser must know. Basic command, yet extremely useful. :w !sudo tee % I often forget to sudo before editing a file I don’t have write permissions on. When I come to save that … Read more
Make Vim show ALL white spaces as a character
As others have said, you could use :set list which will, in combination with :set listchars=… display invisible characters. Now, there isn’t an explicit option which you can use to show whitespace, but in listchars, you could set a character to show for everything BUT whitespace. For example, mine looks like this :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< so, … Read more
What is Vim recording and how can it be disabled?
You start recording by q<letter> and you can end it by typing q again. Recording is a really useful feature of Vim. It records everything you type. You can then replay it simply by typing @<letter>. Record search, movement, replacement… One of the best feature of Vim IMHO.
How to copy to clipboard in Vim?
The * register will do this. In Windows, + and * are equivalent. In unix there is a subtle difference between + and *: Under Windows, the * and + registers are equivalent. For X11 systems, though, they differ. For X11 systems, * is the selection, and + is the cut buffer (like clipboard). http://vim.wikia.com/wiki/Accessing_the_system_clipboard … Read more
How to make vim paste from (and copy to) system’s clipboard?
Be aware that copying/pasting from the system clipboard will not work if :echo has(‘clipboard’) returns 0. In this case, vim is not compiled with the +clipboard feature and you’ll have to install a different version or recompile it. Some linux distros supply a minimal vim installation by default, but if you install the vim-gtk or … Read more