capslock -> ctrl // system key change
inoremap jj <Esc> // esc config to jk
let mapleader = " " // leader to space
Verbs
d: delete
c: change
y: yank (copy)
v: visually select (V for line vs. character)
Modifiers
i: inside
a: around
NUM: number (e.g.: 1, 2, 10)
t: searches for something and stops before it
f: searches for that thing and lands on it
/: find a string (literal or regex)
Nouns
w: word
s: sentence
): sentence (another way of doing it)
p: paragraph
}: paragraph (another way of doing it)
t: tag (think HTML/XML)
b: block (think programming)
Nouns as motion
d2w
cis
yip
ct<
vi file: open your file in vim
:w: write your changes to the file
:q!: get out of vim (quit), but without saving your changes (!)
:wq: write your changes and exit vim
:saveas ~/some/path/: save your file to that locationvim
nmap zz :wq<cr> // a faster way to do :wq
replace
:{作用范围}s/{目标字符}/{替换的字符}/{替换标志}
:%s/first/second/g
A search reference
/{string}: search for string
t: jump up to a character
f: jump onto a character
*: search for other instances of the word under your cursor
n: go to the next instance when you’ve searched for a string
N: go to the previous instance when you’ve searched for a string
;: go to the next instance when you’ve jumped to a character
,: go to the previous instance when you’ve jumped to a character
Basic motions
j: move down one line
k: move up one line
h: move left one character
l: move right one character
Moving within the line
0: move to the beginning of the line
$: move to the end of the line
^: move to the first non-blank character in the line
t": jump to right before the next quotes
f": jump and land on the next quotes
, and ; will repeat the previous t and f jumps.
Moving within the line
0: move to the beginning of the line
$: move to the end of the line
^: move to the first non-blank character in the line
t": jump to right before the next quotes
f": jump and land on the next quotes
, and ; will repeat the previous t and f jumps.
Moving by word
w: move forward one word
b: move back one word
e: move to the end of your wor
W: move forward one big word
B: move back one big word
Moving by sentence or paragraph
): move forward one sentence
}: move forward one paragraph
Moving within the screen
H: move to the top of the screen
M: move to the middle of the screen
L: move to the bottom of the screen
gg: go to the top of the file
G: go to the bottom of the file
^U: move up half a screen
^D: move down half a screen
^F: page down
^B: page up
Jumping back and forth
Ctrl-i: jump to your previous navigation location
Ctrl-o: jump back to where you were
Other motions
:line_number: move to a given line number
^E: scroll up one line
^Y: scroll down one line
在vim中有3中方法可以跳转到指定行(首先按esc进入命令行模式):
1、ngg/nG (跳转到文件第n行,无需回车)
2、:n (跳转到文件第n行,需要回车)
3、vim +n filename (在打开文件后,跳转到文件的第n行
Basic change/insert options
i: insert before the cursor
a: append after the cursor
I: insert at the beginning of the line
A: append at the end of the line
o: open a new line below the current one
O: open a new line above the current one
r: replace the one character under your cursor
R: replace the character under your cursor, but just keep typing afterwards
cm: change whatever you define as a movement, e.g. a word, or a sentence, or a paragraph.
C: change the current line from where you’re at
ct?: change change up to the question mark
s: substitute from where you are to the next command (noun)
S: substitute the entire current line
cis
I
a
C
S
Basic deletion options
x: exterminate (delete) the character under the cursor
X: exterminate (delete) the character before the cursor
dm: delete whatever you define as a movement, e.g. a word, or a sentence, or a paragraph.
dd: delete the current line
dt.: delete delete from where you are to the period
D: delete to the end of the line
J: join the current line with the next one (delete what’s between)
Undo and Redo
u: undo your last action.
Ctrl-r: redo the last action
Using the “.” to repeat your last action
dw
5.
Copying text
y: yank (copy) whatever’s selected
yy: yank the current line
A copy and paste reference
y: yank (copy) from where you are to the next command (noun)
yy: a shortcut for copying the current line
p: paste the copied (or deleted) text after the current cursor position
P: paste the copied (or deleted) text before the current cursor position
:%s /foo/bar/g
:s /foo/bar/g
/delinquent
A[DO NOT PAY] [Esc]
n.
Word Text Objects
iw: inside word
aw: around word
daw
Sentence Text Objects
is: inside sentence
as: around sentence
cis
words: iw and aw
sentences: is and as
paragraphs: ip and ap
single quotes: i' and a'
double quotes: i" and a"
back ticks: i` and a`
parenthesis: i( and a(
brackets: i[ and a[
braces: i{ and a{
tags: it and at
Selecting items with visual mode
character-based: v
line-based: V
paragraphs: Ctrl-v
vi(
vi[
v2i{
vwwy
Vjjd
vip
vipyjjp
Using Macros
qa: start recording a macro named “a”
q: stop recording
@a: play back the macro
Wrapping Content
Using the Surround Plugin you can do some seriously epic stuff in terms of wrapping text with markup.
cs"': for the word you’re on, change the surrounding quotes from double to single
cs'<q></q>: do the same, but change the single quotes to <q></q>
ds": delete the double quotes around something
ysiw[: surround the current word with brackets
ysiw<em></em>: emphasize the current word (it works with text objects!) Want to know what’s crazier about that? It’s dot repeatable!.
Visual Mode: select anything, and then type S. You’ll be brought to the bottom of the window. Now type in what you want to wrap that with, such as <a href="/images">, and then press enter.</a>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!