vi editor
• vi stands for “visual editor”. • vi enter command mode when start. • after entered insert command(i,I,a,A,o,O,R) you can enter text-entry mode.
vi editor commands
• • • • cursor movement delete, replace, paste search, search/replace save/load,edit other file,quit
vi editor commands
• cursor movement
forward word: w back word: start of line: end of line: start of file: end of file: b ^,0 $ gg,:1,1G G
~ ~ ~ ~ Ctrl-D ~ ~ ~ ~ Ctrl-F Ctrl-B
end of word: e
h
j
k
l
go to line nn: :nn,nnG
Ctrl-U
vi editor commands
• delete text
x dw,db,d$,d0, dh,dj,dk,dl dd :d D delete a character delete characters placed in cursor movement range delete a line delete lines in such as 1,5 .,$ same as d$
• replace(change) text
– r,R, cw,cc
vi editor commands
• copy(yank) and paste text
yw,yb,y$,y0, yh,yj,yk,yl yy :y p,:pu,P yank characters placed in cursor movement range yank a line yank lines in paste(put) contents in paste buffer after(p) or before(P) current position(line or character position)paste buffer contains previously deleted or yanked text. paste after line nn
:nnpu
vi editor commands
• search, search/replace text
/text ?text n N /, ? search forward from current position search backward from current position repeat search repeat search in opposite direction repeat search forward or backward
:s/sss/ttt/ replace first occurrence of sss on each line with ttt :s/sss/ttt/greplace every occurrence of sss on each line with ttt
vi editor commands
• save/load
:w :w : w :r :e :n save file as save file with current name save lines in as append contents of file at current position edit other file edit next file given on initial command line
vi editor commands
• miscellaneous
:! :r! :q :q! execute execute and read output into buffer at current position exit vi if file is saved exit vi even if file is not saved
emacs commands
• emacs does not distinguish text-mode and comma nd mode. • emacs’s editing commands are control-sequences or meta-sequences. you should make keystroke wi th Control key or Esc key or Meta key
emacs commands
Ctrl-h t : get tutorial of emacs Ctrl-g : abort command Ctrl-x Ctrl-c : exit emacs Ctrl-x Ctrl-s : save Ctrl-x Ctrl-w : save to different file Ctrl-x Ctrl-f : edit other file Ctrl-x Ctrl-b : list buffers Ctrl-x Ctrl-k : kill a buffer
emacs commands
Search
Ctrl-s str : search forward for str Ctrl-r str : search backward for str Ctrl-s : repeat last search forward Ctrl-r : repeat last search backward Esc : leave search mode Ctrl-k : delete to end of line. Ctrl-a Ctrl-k Ctrl-k : delete current line. Ctrl-x u or Ctrl-_ : undo previous edit action.
emacs commands
Region Command
Ctrl-Spacebar or Ctrl-@ : Set Mark.(use mouse to set mark...) Ctrl-w : Cut Region. Meta-w : Copy Region. Ctrl-y : yank Cut(Copied) Region.
Window Command
C-x 0 : delete window C-x 1 : delete other windows C-x 2 : split window vertical C-x 3 : split window horizontal
emacs commands
Meta-x command executes extended-command(you can execute all command)
Ctrl-h f : describe function Ctrl-h k : describe key Ctrl-h b :list key bindings M-x goto-line n : goto line n M-x kill-buffer : kill buffer (C-x C-k) M-x kill-region : cut region (C-w) M-x kill-ring-save : copy region (M-w) M-x delete-window : delete window (C-x 0)
emacs commands
M-x shell : load a shell in emacs M-x compile : compile current buffer (by default run ‘make’) M-x gdb : load a debugger in emacs M-x gud-break : set break point on current cursor position. Define Key-Bindings M-x global-set-key
emacs commands
Configure your envioronment emacs load ~/.emacs file and interpret the file with emacs-LISP interpr eter on start. setup key-bindings in ~/.emacs file.
(global-set-key [f10] ‘gdb) (global-set-key [f12] ‘shell) (global-set-key “\M-g” ‘goto-line)