How To Delete Blank Lines Using vim

1 |
:g/^$/d |
![]() |
To force VIM to keep the cursor vertically centered in the window while the text scrolls, place this directive in your ~/.vimrc file:
1 |
set so=999 |
To disable it, comment the line out with a double-quote or remove it completely:
1 |
"set so=999 |
Put the following line in your .vimrc file: autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o Or, use this one-off command when in VIM: :set formatoptions-=c formatoptions-=r formatoptions-=o http://vim.wikia.com/wiki/Disable_automatic_comment_insertion
Normally, I have to specify the desired repo on the command line: yum –enablerepo=remi,remi-test install {package name here} To enable the Remi repo so you do not have to specify it on the command line: # perl -pi -e ‘s/enabled=0/enabled=1/g’ /etc/yum.repos.d/remi.repo To disable the Remi repo so you do not have to specify it on […]
I needed to take just the first occurrence of one or more spaces and turn that into a pipe symbol so as to create 2 fields for easy database import:
1 |
:%s/ \+/|/ |
The important thing to note is the inclusion of the backslash in front of the plus (+) sign. That prevents an irritating session of […]
Delete all comment lines: :g/^#/d Delete all blank lines: :g/^$/d
Turn Off: :NoMatchParen Turn On: :DoMatchParen Add the following line to ~/.vimrc :let loaded_matchparen = 1 More information can be found while running vim – just type the following: :help matchparen
Add the following line to your .vimrc file: [code]hi Search ctermfg=white ctermbg=lightgreen guifg=white guibg=black[/code] Color List Color Schemes Color Scroller Use :noh to clear the last search highlight. Place the following in your ~/.vimrc to map the F3 key to a highlight toggle: [code]nnoremap <F3> :set hlsearch!<CR>[/code]
Launch X11 and start GVIM from an xterm in the background. Then type the following into the vim window: [code]:e scp://login@remotehost/full/path/to/the/file[/code] Replace the “login” above with your username on the remote host, “remotehost” is the name or ip of the server and /full/path/to/the/file is the absolute path to the file on the remove host. When […]
Add the following line to your ~/.vimrc file: [code]au BufNewFile,BufRead *.src setfiletype html[/code] The above example assigns type ‘html’ to all files ending in “.src”.