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

相关推荐
NextTech_11 小时前
不想学 vim,怎么改服务器上的配置文件?
服务器·编辑器·vim
行走的陀螺仪3 天前
Claude Code 从入门到实战(三):Hooks、Skills、SubAgents 高级扩展
linux·编辑器·vim
斐夷所非4 天前
Vim 学习速成:理解快捷键
vim
斐夷所非5 天前
Vim 交换文件处理、内容恢复、保存退出与权限提升
vim
by209998 天前
Linux 软件安装与 Vim 编辑
linux·经验分享·vim
FriendshipT12 天前
Vim 完整指南:从入门到高效编辑
linux·人工智能·编辑器·vim·1024程序员节
.道阻且长.12 天前
Linux 基本开发工具:编辑器vim,配置vim
linux·运维·服务器·职场和发展·编辑器·vim·1024程序员节
Rabitebla13 天前
【Linux底层原理】 工具篇(二):Vim 编辑器基础操作与简单配置
linux·c++·编辑器·vim
幸运小圣15 天前
fs 模块完全指南:文件读写、移动删除与文件夹操作(新手友好)【Node.js】
node.js·编辑器·vim
笨笨饿16 天前
#142_VS Code.map文件插件的用法
git·python·stm32·单片机·嵌入式硬件·物联网·vim