VIM
commands
finds and replaces all instances in file
finds and replaces all instances in file (ignore case)
finds and replaces all instances in file (confirm each replacement)
searches the whole file for lines with "search" in them, then runs a substitution s/find/replace on only those lines
finds a date presumed to be in the broken US format (MM-dd-yyyy) and rearranges it into iso format (yyyy-MM-dd.
the key points in this are the \( and \) surround a part of the searched text we want to reuse in out substitution, and \1, \2, etc refer back to these parts of the text
for the range between 'a and 'b, for lines with the string "abc" on them, replace the first occurance of "def" with an incrementing number starting from 10. I commonly have "abc" and "def" set to the same thing (for some reason it doesnt increment if you leave out the "g/abc/" part).
shortcuts
autocomplete words
show spelling suggestions
add to dictionary
split panes
new pane
open filename.txt in a new pane
open filename.txt in a new vertical pane
cycle through panes
select pane below
select pane above
all panes equal height
increase selected pane height by 1
decrease selected pane height by 1
VIM RegEx stuff
start of line
end of line
the ^M character that windows users leave on the end of lines
.vimrc
Use F5 to toggle en_au spelling checker
Use Ctrl-a/Ctrl-e to move to the start/end of a line, emacs style i believe
tells vim that your terminal has a dark background, dont use light colours for text
backspace over anything instead of that broken backspace some distros seem to include
keep backup files somewhere neat and tidy, instead of having tilde files all over the place
search highlights all matching terms
case insensitive searching
auto-completion automatically adjusts case of keywords
line numbers
highlights the matching brace briefly when highlighted
turns on a row and column highlight to make it easy to find the cursor
switches to soft tabs, 2 characters wide
:%s/find/replace/gfinds and replaces all instances in file
:%s/find/replace/gifinds and replaces all instances in file (ignore case)
:%s/find/replace/gcfinds and replaces all instances in file (confirm each replacement)
:%g/search/s/find/replacesearches the whole file for lines with "search" in them, then runs a substitution s/find/replace on only those lines
:s/\(\d\d\)-\(\d\d\)-\(\d\d\d\d\)/\3-\1-\2finds a date presumed to be in the broken US format (MM-dd-yyyy) and rearranges it into iso format (yyyy-MM-dd.
the key points in this are the \( and \) surround a part of the searched text we want to reuse in out substitution, and \1, \2, etc refer back to these parts of the text
:let i=10 | 'a,'bg/abc/s/def/\=i/ |let i=i+1for the range between 'a and 'b, for lines with the string "abc" on them, replace the first occurance of "def" with an incrementing number starting from 10. I commonly have "abc" and "def" set to the same thing (for some reason it doesnt increment if you leave out the "g/abc/" part).
shortcuts
C^pautocomplete words
z=show spelling suggestions
zgadd to dictionary
split panes
C^w, nnew pane
:sp filename.txtopen filename.txt in a new pane
:vsp filename.txtopen filename.txt in a new vertical pane
C^w, wcycle through panes
C^w, down arrowselect pane below
C^w, up arrowselect pane above
C^w, =all panes equal height
C^w, +increase selected pane height by 1
C^w, -decrease selected pane height by 1
VIM RegEx stuff
^start of line
$end of line
C^v + C^mthe ^M character that windows users leave on the end of lines
.vimrc
:map <F5> :setlocal spell! spelllang=en_au
:imap <F5> <ESC>:setlocal spell! spelllang=en_auUse F5 to toggle en_au spelling checker
:map <C-a> 0
:map <C-e> $
:cmap <C-a> <home>
:cmap <C-e> <end>
:imap <C-e> <ESC>$i<right>
:imap <C-a> <ESC>0iUse Ctrl-a/Ctrl-e to move to the start/end of a line, emacs style i believe
set background=darktells vim that your terminal has a dark background, dont use light colours for text
set backspace=indent,eol,startbackspace over anything instead of that broken backspace some distros seem to include
set backup
set backupdir=~/tmp/vimkeep backup files somewhere neat and tidy, instead of having tilde files all over the place
set hlsearchsearch highlights all matching terms
set ignorecasecase insensitive searching
set infercaseauto-completion automatically adjusts case of keywords
set numberline numbers
set showmatchhighlights the matching brace briefly when highlighted
set cursorcolumn
set cursorline
hi cursorcolumn ctermbg=redturns on a row and column highlight to make it easy to find the cursor
set expandtab
set tabstop=2switches to soft tabs, 2 characters wide
Labels: vim

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home