Home Vim Snippets
Post
Cancel

Vim Snippets

Collection of random snippets including my .vimrc and commands for file/string manipulation in Vim.

.vimrc


1
2
3
4
5
6
syntax on
colo peachpuff 
filetype plugin indent on 
set tabstop=4 
set shiftwidth=4 
set expandtab 


Commands


Command Description
%le move everything left - remove white space at start of each line
1,$join join all lines into single line
dw delete current letter
dd delete current line
5dd delete 5 lines
d$ delete to end of line
d0 delete to beginning of line
1,.d delete to beginning of file
.,$d delete to end of file
g/^$/d remove all blank lines
%s/$/*/g add string to end of each line
%s/^/*/g add string to start of each line
%s/.*\zehttp// remove everything before ‘http’ on each line
%s/,/./g replace every comma with full stop (this can be done for any two things)
%s/ //g remove all spaces
%s/^.{0,4}// remove first 4 chars each line
%s/(…..)/\1 /g add a space every 5 chars each line
%s/\s.*//g remove everything after the first word on each line
%s/\v.*\s(\S+)$/\1/ delete everything bar last word on each line
Contents