vim

Chapter 1: Basic Editing

alias

  • h: <Left>, <BS>, CTRL-H and CTRL-K
  • j: <Down>, <NL>, CTRL-J, and CTRL-N
  • k: <Up> and CTRL-P
  • l: <Right> and <Space>

undo

  • If undo too many times, press CTRL-R (redo) to reverse the preceding command.
  • U(undo line)

Second U undoes the preceding U

edit

  • a: append after the cursor
  • 3a!<Esc>

help

  • :help (:h, <F1>, <Help>)
  • To get out of the help system, use ZZ
  • |:help| (颜色是 cyan)
  • CTRL-] (jump to tag)
  • CTRL-T (pop tag)
  • *help.txt*
  • help deleting
  • help CTRL-A "default normal mode
  • help i_CTRL-H "mode
  • help -t "option
  • help 'number' "set nu
  • help <Up> "Special keys
    image.png

    Vim是Ex行编辑器的可视模式。或者说,Ex是Vim的底层行编辑器
  • set helplang=de,it "Vim always searches English as a last resort.

tutor

  • vimtutor
  • help tutor

Chapter 2: Editing a Little Faster

word movement

  • $, <End>, and <kEnd>. (The <kEnd> key is Vim's name for the keypad End key.)
  • 2$
  • ^
  • <Home> or <kHome> 0 much faster
  • 5f<Space>
  • t: one character before
  • 3G
  • 25%
  • %

Scrolling Up and Down

  • CTRL-U
  • CTRL-D

Delete

  • d3w or 3dw "3d2w
  • D=d$

Change

  • cc
  • c$=C

Join lines

  • J

Replace

  • r{char}
  • 5ra to replace the first five characters with a
  • 5r<Enter> replaces five characters with one <Enter>

Case

  • ~

Keyboard Macros

  • q{character}...q
  • @<reg>

Digraphs

  • dig
  • CTRL-K{c}{c}

Chapter 3: Searching

  • .*[]^%/?~$
  • q/ "History Window, q?
  • :nohlsearch "To clear the current highlighting

Chapter 4: Text Blocks and Multiple Files

  • p command placed the text on the line after the cursor
  • V: line visual mode
  • v: simple visulal mode
  • Marks
'{mark}moves to the beginning . 
`{mark} moves to the marked line and column.
  • d'a
  • :marks


    image.png
  • Y = yy, 不同于 D 或 C

Filtering

  • !sort<Enter>
  • !!ls
  • !!date

edit another file

  • :e! file "close current
  • :enew "new unnamed buffer
  • :view file "readonly, use :write! force save
  • :wnext
  • :set autowrite
  • :set 'autowriteall
  • :args "which File Am I On
  • :Next 和 next 不同
  • :rewind "first
  • register (#) contains the name of last file.
  • CTRL-^ to alternative
  • [count]CTRL-^ goes to the count file on the command line.
  • :match Error /TOOD/ ":highlight show highlight names
  • :match none
There are can be three matches active at one time. 
These are set by the :match, :2match, and :3match commands. 
If some text is matched by more than one command, the lowest one wins.

Chapter 5: Windows and Tabs

  • CTRL-Wc (CTRL-W CTRL-C)
  • :split +/printf three.c
  • CTRL-Wn (CTRL-W CTRL-N, :new)
  • :new, :vnew
  • :vertical :sview
  • CTRL-W=
  • count CTRL-W_
  • :resize

buffers

If it has a window on the screen, it is a buffer;
if it is not on the screen, it is not a buffer.
  • :hiden
Active Appears onscreen.
Hidden A file is being edited, but does not appear onscreen.
Inactive The file is not being edited, but keep the information about it anyway.
  • :buffers can also be written as :ls, :files
- Inactive buffer.
h Buffer is hidden.
% Current buffer.
# Alternate buffer.
+ File has been modified.
  • :sbuffer number
  • :vertical sbuffer number
  • :sbmodified count
  • :set hidden

Tabs

  • :tabnew, tabedit
  • :tabclose 2
  • :tabonly
  • :tabnext 3
  • gt (<C-PageDown>)
  • gT (<C-PageUp>)
  • :tabfirst
  • :tablast
The CTRL-Wgf command opens a new tab and starts to edit the file who's
name is under the cursor. Vim will search for the file using the same algorithm
as it uses for the :find command. The CTRL-WgF command does the same thing,
only it goes a step farther. It not only starts editing the file in a new tab, but
jumps to the line number following the file name.
  • :tabfind

Chapter 6: Basic Visual Mode

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 222,627评论 6 517
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 95,180评论 3 399
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 169,346评论 0 362
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 60,097评论 1 300
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 69,100评论 6 398
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,696评论 1 312
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 41,165评论 3 422
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 40,108评论 0 277
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,646评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,709评论 3 342
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,861评论 1 353
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,527评论 5 351
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 42,196评论 3 336
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,698评论 0 25
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,804评论 1 274
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 49,287评论 3 379
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,860评论 2 361

推荐阅读更多精彩内容