Vi Notes
From Federal Burro of Information
Search forard
/searchterm
search backward
?searchterm
edit binary file in vi
:%!xxd
Turn on line numbering
:set number
turn off:
:set nonumber
End of file
G
vim turn of auto indent
Use while pasting text.
:set paste <then paste you stuff> :set nopaste
tai64nlocal file in vi
:%!tai64nlocal
insert today's date
:r !date
set tabs to be the ENGDEV way in vi
also called indenting
in the file:
/* ex: set tabstop=4 expandtab: */
or in ~/.vimrc
set tabstop=4 set expandtab
turn off colour
:syntax off
fancy find replace
uses match substitution. (X) -> \1
convert:
Target[server-5.location-5.mem]: `/usr/local/bin/snmp_mem_usage.pl public 192.168.5.5 real`
to
Target[server-1.location-5.Swap]: memTotalSwap.0&memTotalSwap.0:public@192.168.5.129:161::::2 - memAvailSwap.0&memAvailSwap.0:public@192.168.5.129:161::::2
in two (in vi):
%s: `/usr/local/bin/snmp_mem_usage.pl public ::g %s/:\(.\+\) real`/ memTotalReal.0\&memTotalReal.0:public@\1:161::::2 - memAvailReal.0\&memAvailReal.0:public@\1:161::::2/
or more generically, reversing stuff:
- %s/(brackets1) stuff (brackets2)/\2stuff\1/g
converts:
brackets1 stuff brackets2
to
brackets2 stuff brackets1
No wrap
:set nowrap
Convert to unix file format
:set ff=unix
- unix LF only (each line ends with an LF character).
- dos CRLF (each line ends with two characters, CR then LF).
- mac CR only (each line ends with a CR character).
Unicode /Special characters
- what am I looking at?
- move the cursor over the character and issue "ga"
For example:
Submitted Jan 12Â ga <Â > 160, Hex 00a0, Octal1240
Find replace:
:%s/\%xNN//g
for example:
:%s/\%xa0//g
Also See
- http://www.geocities.com/volontir/ - tuns of good stuff.
- Learn TAGS , do it now. http://vimdoc.sourceforge.net/htmldoc/usr_29.html