2023-08-05 05:00:07

在Vim中改变情况

在Vim中是否有更改所选文本大小写的命令?


当前回答

参考以下方法:

 ~    : Changes the case of current character

 guu  : Change current line from upper to lower.

 gUU  : Change current LINE from lower to upper.

 guw  : Change to end of current WORD from upper to lower.

 guaw : Change all of current WORD to lower.

 gUw  : Change to end of current WORD from lower to upper.

 gUaw : Change all of current WORD to upper.

 g~~  : Invert case to entire line

 g~w  : Invert case to current WORD

 guG  : Change to lowercase until the end of document.

 gU)  : Change until end of sentence to upper case

 gu}  : Change to end of paragraph to lower case

 gU5j : Change 5 lines below to upper case

 gu3k : Change 3 lines above to lower case

其他回答

此外,尽管所有这些都说了,它不是为了视觉选择:

有操作符: 用法:操作者动作 参见:h运算符和:h运动

操作符可以是

c   change
d   delete
gu  make lowercase
gU  make uppercase
...

这些动作大多是众所周知的:

0  first character of the line
$  end of line
aw a word
iw inner word
...

所以你只需要记住一些操作符和动作(有很多,但你会有一些最喜欢的)。

通过这种方式,您可以得到上面的@ungalnanban列表。


在Vim cheatsheet - devhints.io上找到的

参考以下方法:

 ~    : Changes the case of current character

 guu  : Change current line from upper to lower.

 gUU  : Change current LINE from lower to upper.

 guw  : Change to end of current WORD from upper to lower.

 guaw : Change all of current WORD to lower.

 gUw  : Change to end of current WORD from lower to upper.

 gUaw : Change all of current WORD to upper.

 g~~  : Invert case to entire line

 g~w  : Invert case to current WORD

 guG  : Change to lowercase until the end of document.

 gU)  : Change until end of sentence to upper case

 gu}  : Change to end of paragraph to lower case

 gU5j : Change 5 lines below to upper case

 gu3k : Change 3 lines above to lower case

可视地选择文本,然后U为大写或U为小写。要在可视选择中交换所有的大小写,按~(波浪号)。

在不使用可视选择的情况下,gU<motion>将使动态字符大写,或使用gU<motion>作为小写。

要了解更多信息,请参阅Vim的change.txt帮助文件中的第3节。