Vim Snippets

less than 1 minute read

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


syntax on
colo peachpuff 
filetype plugin indent on 
set tabstop=4 
set shiftwidth=4 
set expandtab 


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 word
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
%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