1.linux, mac terminal shortcuts
Shortcuts for linux/mac to enter terminal commands:
ctrl+c, stop running ctrl+s, pause screen output ctrl+q, resume screen output
ctrl+a , skip to the beginning of the line ctrl+e , skip to the end of the line ctrl+left , skip to the previous word ctrl+right , skip to the next word ( alt shortcut key under mac)
ctrl+u , delete the content from the current to the beginning ctrl+k , delete the content from the current to the end ctrl+w, delete a word from the current to the beginning
Common shortcut keys for opening/closing/switching terminals in mac system
cmd+t: open a terminal tab cmd+shift+left: switch between tabs cmd+shift+r: switch between tabs
cmd+n: open a new terminal window cmd+left: window switch cmd+right: window switch
cmd+d: split the current window vertically cmd+shift+d: merge vertically split windows
2.vim shortcut keys
Move the cursor position:
hjkl shift+4($) : end g+_ : end 0 : beginning shift+6(^) : beginning
w : next word (contains only letters) W : next word (contains special symbols) b : previous word B : previous word e : end of next word E: end of next word
ctrl+f:forward page ctrl+b:backward page ctrl+d:forward 1/2 page ctrl+u:backward 1/2page ctrl+e:next line move ctrl+y:previous line move
G:文末 gg:文头 nG:line n H:head line of page M:middle line of page
Insert mode toggle:
esc : enter command mode i : insert a at the current position : insert the next character o : insert the next line O : insert the previous line cw : delete the current position and the next word insert x : delete the current character
copy and paste:
dd : delete a line p : paste yy : copy a line ndd nyy : delete copy n lines
. : repeat previous cmd
100idesu : Insert 100 times desu . : Copy again 100 times
Find, replace:
/pattern search forward ?pattern search backward n :next shift+n :reverse next
s/pattern1/pattern2 : replace s/pattern1/pattern2/g : replace all current lines
1, $s/pattern1/pattern2/g : replace all lines starting from the first line
编程实际相关: *查找当前单词的下一次出现 #查找当前单词的上一次出现
块操作:
ctrl+v:开始选择要操作的块
I 然后 #插入多行注释,
d:删除 s:删除后替换
分屏操作:
split:上下分屏 vsplit:左右分屏
ctrl+w+hjkl:切换分屏到不同方向
e:打开文件