Posts 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


CommandDescription
%lemove everything left - remove white space at start of each line
1,$joinjoin all lines into single line
dwdelete current letter
dddelete current line
5dddelete 5 lines
d$delete to end of line
d0delete to beginning of line
1,.ddelete to beginning of file
.,$ddelete to end of file
g/^$/dremove all blank lines
%s/$/*/gadd string to end of each line
%s/^/*/gadd string to start of each line
%s/.*\zehttp//remove everything before ‘http’ on each line
%s/,/./greplace every comma with full stop (this can be done for any two things)
%s/ //gremove all spaces
%s/^.{0,4}//remove first 4 chars each line
%s/(…..)/\1 /gadd a space every 5 chars each line
%s/\s.*//gremove everything after the first word on each line
%s/\v.*\s(\S+)$/\1/delete everything bar last word on each line
This post is licensed under CC BY 4.0 by the author.