160 likes | 593 Views
vi editor. vi stands for “ vi sual 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. Ctrl -B. ~ ~ ~
E N D
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
Ctrl-B ~ ~ ~ ~ ~ ~ ~ ~ Ctrl-U Ctrl-D h j k l Ctrl-F vi editor commands • cursor movement forward word: w back word: b end of word: e start of line: ^,0 end of line: $ start of file: gg,:1<Enter>,1G end of file: G go to line nn: :nn<Enter>,nnG
vi editor commands • delete text x delete a character dw,db,d$,d0, delete characters placed in cursor dh,dj,dk,dl movement range dd delete a line :<range>d<Enter> delete lines in <range> such as 1,5 .,$ D same as d$ • replace(change) text • r,R, cw,cc
vi editor commands • copy(yank) and paste text yw,yb,y$,y0, yank characters placed in cursor yh,yj,yk,yl movement range yy yank a line :<range>y<Enter> yank lines in <range> p,:pu<Enter>,P 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. :nnpu<Enter> paste after line nn
vi editor commands • search, search/replace text /text<Enter> search forward from current position ?text<Enter> search backward from current position n repeat search N repeat search in oppisite direction /<Enter>, ?<Enter> repeat search forward or backward :<range>s/sss/ttt/<Enter> replace first occurrence of sss on each line with ttt :<range>s/sss/ttt/g<Enter> replace every occurrence of sss on each line with
vi editor commands • save/load :w <name> <Enter> save file as <name> :w<Enter> save file with current name :<range> w <name> <Enter> save lines in <range> as <name> :r <name> <Enter> append contents of file <name> at current position :e <name> <Enter> edit other file <name> :n <Enter> edit next file given on initial command line
vi editor commands • miscellaneous :!<command><Enter> execute <command> :r!<command><Enter> execute <command> and read output into buffer at current position :q<Enter> exit vi if file is saved :q!<Enter> exit vi even if file is not saved
emacs commands • emacs does not distinguish text-mode and command mode. • emacs’s editing commands are control-sequences or meta-sequences. you should make keystroke with Control key or Esc key or Meta key
emacs commands Ctrl-ht : 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 windowvertical 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-hk : describe key Ctrl-hb :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 interpreter 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)