Vim User Manual 阅读笔记 User_04.txt Making small changes 作微小改动

*04.1* Operators and motions 操作符和移动

小写 d4w 和 d4e 有一点点差别,

|-----|-------------------------------------------------|
| d4w | 删完之后停留在第5个词首部,删除从(当前字符 到 第四个词末尾)且不留第四个词末尾的空格; |
| d4e | 删完之后停留在第5个词前的空格,删除从(当前字符 到 第四个词末尾)且保留第四个词末尾的空格; |

Operation-motion

04.2* Changing text 改动文本

用 c

c2w

cw ce 一样

删除整行 dd

修改整行 cc

修改至行末c ,等价 d 然后 a insert mode

SHORTCUTS

Some operator-motion commands are used so often that they have been given a

single-letter command:

x stands for dl (delete character under the cursor)

X stands for dh (delete character left of the cursor)

D stands for d$ (delete to end of the line)

C stands for c$ (change to end of the line)

s stands for cl (change one character)

S stands for cc (change a whole line)

WHERE TO PUT THE COUNT 把计数放在哪边

|----------|------------------------|
| 数字-操作 | 将 3dw 理解为 3(dw),做三次dw |
| 操作-数字-操作 | 将 d3w 理解为:开始删除,往右移动三个w |

REPLACING WITH ONE CHARACTER 以一个字符代替

r小写 按下去之后等待输入,不需要按 Esc

*04.3* Repeating a change 重复一个改动

英文句号. 重复最近一次的变化, except for "u" (undo), CTRL-R (redo) and commands that start with a colon (:).

*04.4* Visual mode 可视化模式

SELECTING LINES

按小写v进入 可视化模式

按大写V,整行可视化,上下移动整行选择

SELECTING BLOCKS 选择块,块选择

块选择 CTRL-V 选择块,按块选择

可视化模式visual模式下,o命令在两端切换,块选择模式下,大写O在各个角之间切换。与在常规模式下不同。

*04.5* Moving text 移动文本

dd删除整行

p, put

P, put before cursor

SWAPPING TWO CHARACTERS 交换两个字符

小写xp

*04.6* Copying text 复制文本

The "y" operator copies text into a register. Then a "p" command

can be used to put it.

Yanking yw/ye/yy

|-----|--------------|
| 大写D | 删除当前位置到行末的内容 |
| 大写Y | 复制当前位置到行末的内容 |

*04.7* Using the clipboard 使用剪贴板

使用系统剪贴板

To copy a line to the clipboard: >

"*yy

To put text from the clipboard back into the text: >

"*p

More about the clipboard can be found in section |09.3| and here: |clipboard|.

*04.8* Text objects 文本对象

光标在词中间,需要删除整词,daw,附带删除后续的所有空格,如果在行末就把该词前面的空格也删除

aw是一个text object

cis, is for "Inner Sentence" 一句话中间,修改不包括句末空格,保留句末空格。

cas, as "A Sentence",修改包括句末空格,不保留句末空格。

同理 das/dis

可使模式下, visual mode, as/is可以进行选择;

也可以直接用 vas/vis 进行选择

似乎基于编辑器对英文标点的理解,对英文比较有效,对中文不太友好。

*04.9* Replace mode 替换模式

R 一直改到 esc; r 改一个字符

R时候,用<backspace>可以局部回复

x delete character under the cursor (short for "dl")

X delete character before the cursor (short for "dh")

D delete from cursor to end of line (short for "d$")

dw delete from cursor to next start of word

db delete from cursor to previous start of word

diw delete word under the cursor (excluding white space)

daw delete word under the cursor (including white space)

dG delete until the end of the file

dgg delete until the start of the file

相关推荐
阿钱真强道3 天前
06 嵌入式操作系统 | vim 与软件管理:apt / 源码编译
ubuntu·vim·嵌入式·apt·源码编译
Tairitsu_H5 天前
[Linux] 编辑器vim、编译器和动静态链接
linux·vim·gcc·g++·动态链接·静态链接
ThornArmor7 天前
《向内深潜,向外飞掠》
c语言·开发语言·c++·vim·visual studio
rain bye bye9 天前
对比 目录 diff -rq
vim
典典分享指南10 天前
AI 配图的排版规范
macos·docker·github·vim·visual studio
cuncaojin12 天前
vim系列之Tmux
vim·tmux
典典分享指南13 天前
DeepSeek Harness 开源贡献手记:从 Issue 到 Merge 的完整旅程
jupyter·github·vim·idea·visual studio
脉动数据行情113 天前
Node.js WebSocket 实现贵金属实时行情监听 伦敦金 / 伦敦银自动重连方案
websocket·node.js·vim
Sayai14 天前
不重新打包,vim 直接改 jar 包内的前端文件:原理、步骤与避坑
前端·vim·jar
Java后端的Ai之路15 天前
Git pull弹出vim编辑器完整排查指南
开发语言·人工智能·git·编辑器·vim