VIM Tutorial

Type vimtutor in your terminal.

VIM has three modes:

  • To enter insert mode, hit i
  • To exit insert mode, hit <ESC>
  • To enter visual mode, hit v
  • To exit visual mode, hit <ESC>
  • insert mode- stuff you type is added to the buffer
  • normal mode- keys you hit are interpreted as commands
  • visual mode- allows you to select blocks of text

I use a vim gem below, you can clone it on Github.

https://github.com/carlhuda/janus


Some useful commands for me:

vim -o[number] . - open ‘.’ with [number] windows

operator [number] motion

d - delete word/line, and store it in a vim register

dw - delete word

d2w - delete two words

dd - delete the line

d2d - delete two lines

v - visual mode: highlight the text

[ctrl + v] - block visual mode, move the cursor with hjkl

I# [ESC] - insert ‘#’ to every line selected

y - yank (copy) the highlighted text

y2w - yank two words

p - paste

f - find

[number]f[character] - find the next [number]th [character]

3fc - find the next third ‘c’ character

$ - end of the line

d$ - delete to the end of the line

w - move to the start of the next word

2w - jump to the start of the next two words

e - move to the end of the current word

2e -  jump to the end of the next two words 

0 - move to the start of the line

r - replace

R - enter replace mode: replace more than one character

c - correct

ce - correct from current letter to the end of the word, and place you in Insert mode

c$ - correct to the end of the line, and place you in Insert mode

c2w - correct the next two words, and place you in Insert mode

[number] G - move to the line [number]

124 G - move to line 124

% - find a matching ), ] or }

^ - move to the first non-blank character of this line

g_ - move to the last non-blank character of this line

:s/old/new/g - substitute ’new’ for ‘old’ (s means substitute, g means globally in the line)

:![shell-command] - execute an external shell command

o - open command: open up a line BELOW the cursor and place you in Insert mode

O - open command: open up a line ABOVE the cursor and place you in Insert mode

a - append command: insert text AFTER the cursor

A - append command: insert text after the end of the line

[ctrl + n(or p)] - auto complement

:set option

:set nu - set number of current file

:set ic - set ignore case when searching

:set noic - disable ignore case

:set hls - highlight all matching phrases 

ctrl + p - search a file in directory left

ctrl + w + v - open a new tab in vim


without ending…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值