How To Delete Blank Lines Using vim

Author: , June 19th, 2014

How To Change Cursor-position-based Window Scrolling In VIM

Author: , September 30th, 2011

To force VIM to keep the cursor vertically centered in the window while the text scrolls, place this directive in your ~/.vimrc file:

To disable it, comment the line out with a double-quote or remove it completely:

How To Turn Off Auto-Comment In Vim

Author: , September 29th, 2011

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

How To Enable A Repo Using Perl

Author: , September 4th, 2011

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 […]

How To Match Multiple Spaces In VIM

Author: , July 22nd, 2011

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:

The important thing to note is the inclusion of the backslash in front of the plus (+) sign. That prevents an irritating session of […]

How To Search For And Delete Lines Globally In Vim

Author: , November 27th, 2010

Delete all comment lines: :g/^#/d Delete all blank lines: :g/^$/d

How To Turn Off Paren Matching In VIM

Author: , November 24th, 2010

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

How To Change The Search Highlight Color In VIM

Author: , October 22nd, 2010

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]

Editing Remote Files In GVIM With SCP

Author: , October 5th, 2010

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 […]

How To Get VIM to Syntax Highlight A New File Extension

Author: , October 4th, 2010

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”.