倒腾vim时候的cheatsheet,vim模式可以使双手脱离鼠标,还是很便捷的,虽然有一丢丢学习成本,但还是很值得的。

Why Vim

Just because your workflow will be interrupted frequently when navigating your cursor is needed. But you can navigate easily with Vim compared with other text editor. Though it will take some time to get used to Vim, but in the long run, it's definitely worth it.

Here is quick reference of the most commonly used vim command, hope it will help. So let's get started!

Modes

Mode matters!

command mode

Where you start with and you will always here when not editing

insert mode

  • insert, i or I to insert at current position or beginning
  • append, a or A to append after current position or end
  • open, o or O to open a new line below or above

last line mode

Enter command : in command mode(normal mode) to enter, and you will be able to perform amazing tasks.

  • :q, quit
  • :q!, force quit, changes will not be save
  • :wq, write and quit
  • :!ls, you can issue linux or unix commands here
  • :set number, you can issue configuration for this session

Deletion

  • dw, delete word from cursor on
  • db, delete word backward
  • dd, delete line(couldn't be more convenient)
  • d$or D, delete to end of line
  • d^, delete to beginning of line
  • x, delete character

Copy

Basic the same with deletion but begin with y not d.

  • yw, copy word from cursor on
  • yb, copy word backword
  • yy, copy current line(yy and p combo is very convenient)
  • y$, copy to end of current line
  • y^, copy to beggining of current line
  • v, start to copy text block
  • V, linewise copy

Paste

Used after delete or yank to recover lines

  • p, paste below cursor
  • P, paste above cursor
  • u, undo last change
  • U, restore line

Change

Use to change word

  • cw, change current word to a new word from cursor
  • ciw, change inner word
  • :/, search forward
  • :?, search backword
  • n, next
  • hjkl to navigate around
  • gg to file beginning
  • G to file end
  • 0 or ^ to beginning of line
  • $ to end of line

Resize windows

  • resize 60
  • res +5
  • vertical res +5
  • vertical resize 80

Mappings

Useful for some cases, I fall in love with vim mode when I know can be replaced with jj command.

  • add inoremap jj <Esc> to file ~/.vimrc
  • also you can enable Esc by adding inoremap <Esc> <Nop>

results matching ""

    No results matching ""