Upload
myname2lovess
View
218
Download
0
Embed Size (px)
Citation preview
8/13/2019 VI and Emacs
1/15
8/13/2019 VI and Emacs
2/15
cursor movement
delete, replace, paste
search, search/replace
save/load,edit other file,quit
vi editor commands
8/13/2019 VI and Emacs
3/15
cursor movement
vi editor commands
h j k l
~
~
~
~~
~
~
~
Ctrl-D
Ctrl-F
Ctrl-U
Ctrl-B
forward word: w
back word: b
end of word: e
start of line: ^,0
end of line: $
start of file: gg,:1,1G
end of file: G
go to line nn: :nn,nnG
8/13/2019 VI and Emacs
4/15
delete text
vi editor commands
replace(change) text
r,R, cw,cc
x delete a character
dw,db,d$,d0, delete characters placed in cursordh,dj,dk,dl movement rangedd delete a line
:d delete lines in such as 1,5 .,$D same as d$
8/13/2019 VI and Emacs
5/15
copy(yank) and paste text
vi editor commands
yw,yb,y$,y0, yank characters placed in cursoryh,yj,yk,yl movement rangeyy yank a line
:y yank lines in p,:pu,P paste(put) contents in paste buffer after(p) or
before(P) current position(line or characterposition)paste buffer contains previouslydeleted or yanked text.
:nnpu paste after line nn
8/13/2019 VI and Emacs
6/15
vi editor commands search, search/replace text
:s/sss/ttt/ replace first occurrence of sss oneach line with ttt
:s/sss/ttt/greplace every occurrence of sss oneach line with
/text search forward from current position
?text search backward from current position
n repeat search
N repeat search in oppisite direction
/, ? repeat search forward or backward
8/13/2019 VI and Emacs
7/15
vi editor commands save/load
:w save file as
:w save file with current name
: w save lines in as :r append contents of file
at current position:e edit other file :n edit next file given on initial
command line
8/13/2019 VI and Emacs
8/15
vi editor commands miscellaneous
:! execute :r! execute and read
output into buffer at current position:q exit vi if file is saved
:q! exit vi even if file is not saved
8/13/2019 VI and Emacs
9/15
emacs commands emacs does not distinguish text-mode and
command mode. emacss editing commands are control-sequences
or meta-sequences. you should make keystroke
with Control key orEsc key orMeta key
8/13/2019 VI and Emacs
10/15
emacs commandsCtrl-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 fileCtrl-x Ctrl-f : edit other file
Ctrl-x Ctrl-b : list buffers
Ctrl-x Ctrl-k : kill a buffer
8/13/2019 VI and Emacs
11/15
emacs commandsSearch
Ctrl-s str: search forward for strCtrl-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.
8/13/2019 VI and Emacs
12/15
emacs commandsRegion 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 CommandC-x 0 : delete window
C-x 1 : delete other windows
C-x 2 : split windowvertical
C-x 3 : split window horizontal
8/13/2019 VI and Emacs
13/15
emacs commandsMeta-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)
8/13/2019 VI and Emacs
14/15
emacs commandsM-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-BindingsM-x global-set-key
8/13/2019 VI and Emacs
15/15
emacs commandsConfigure 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)