vi adalah editor 'standar' UNIX, dengan vi/vim semuanya jadi mudah,
cuma saja cukup banyak yang perlu diingat, dokumen ini cuma catatan
untuk mengingat perintah dasar yang penting...
Gunakan file .vimrc untuk mempermudah dan meng-costumize vim anda..
learn its easy things until you fall in love with..
Vi banyak digunakan oleh programmer, dengan fasilitas syntax highlighting
vim sangat membantu dan terlihat begitu indah :-)
vi reference
vi file1 file2 file3
:next go to the next file in the file list
:rewind go to the first file in the file list
:last go to the last file in the file list
:qa! exit all files at once without save
:wqa exit all files at once with save all
:e /path/to/file.txt load a new file into the editor
:read /path/to/file_to_be_inserted.txt add a file into currently editing
O Open new line for insert above the current line.
o insert below the current line
:w save, not exit
:wq save and exit
:x! save and exit
:q! exit without save
Cursor movement
^ to first char (non-blank) in line
0 to first char in line
$ to end char in line
% to matching sets of {}, [], or ()
| to first coloum
20| jump 20 coloum
w move one word forward
b move one word backward
{ move between paragraf
}
( move between sentences
)
gg jump to begining of file
G jump to the end of file
^F page forward
^B page back
x delete
dw delete word
dd delete line
dgg delete to begining
dG delete to end
u undo
- redo
P put/paste before cursor
p put/paste after cursor
yw yank/copy word
yy or Y yank/copy line
8dd
y copy (yank) whithout deleteing it
cc change current line (delete and insert mode)
cw change one word
c20| change from cursor to the next 20 coloum
R replace, not deleted
^V insert an escape character, vi must be in insert mode
ma mark as 'a character
'a jump to mark
d'a delete fom this cursor (line) to 'a mark
d20| delete until next 20 coloum
/name search 'name' forawrd
?name search 'name' backward
n next search down
N next search up
/n.me . means any char, it can be name, nbme, ncme
/n[aiueo]me [aiueo] means anya char macthes a, i, u, e, or o
/[EFGHIJ] or /[E-J] seach char E, F, G, H, I, J
/n[^a]me [^a] matches any char except a
/n*me * matches any chars ex: naame nbme nabcme
fx seaech one char x in the current line
; next
/^E find a line begin with letter E
/end$ find a line end with letter end
/thi\$ search word thi$
ex command, command begin with a colon ":"
:%s/new/old/g
% is an ex address
s is the substitution command
/ separator it can be any char, for ex:
g tells if there more than one match in a line
:%s@new@olg@g
Address Meaning
---------------- --------------
no address given The current line
% The whole file
3 Line 3
5,8 Lines 5 through 8
. The current line
+x x lines after the current line
-x x lines before the current line
.,.+2 The current line and the next 2 lines
$ The last line
10,$ Line 10 through the last line
ex:
:2,6d delete line 2 until line 6
:g/something/d delete all lines macthing word 'something'
:1,$s/pattern_to_find/pattern_to_replace/g
:s/pattern_to_find/pattern_to_replace replace in a line
:%s/pattern_to_find/pattern_to_replace replace all in a file
:syntax on mengaktifkan mode color editor
:set number pemberian nomor pada line
:set cindent c like indent
:set shiftwidth=4 set [TAB] width
:set ignorecase
!!!!! learn the unix regular expression
---
eryan12@yahoo.com
http://eryan.dhs.org
               (
geocities.com/hackermuda)