【问题标题】:Changing case in Vim在 Vim 中更改大小写
【发布时间】:2011-02-26 03:01:08
【问题描述】:

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

【问题讨论】:

标签: vim


【解决方案1】:

查看以下方法:

 ~    : 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

【讨论】:

  • 在这种情况下,aw 和 iw 命令会做同样的事情,因为空格没有大小写。我相信我们可以节省一次击键并使用 w 版本的命令。这里有什么理由使用aw吗?
  • guw 将大小写从当前位置更改到单词末尾。 guawguiw 改变整个单词的大小写。
【解决方案2】:

Visual select the text,然后 U 表示大写或 u 表示小写。要交换视觉选择中的所有大小写,请按 ~(波浪号)。

如果不使用视觉选择,gU<motion> 会将 motion 中的字符变为大写,或者使用 gu<motion> 变为小写。

有关更多信息,请参阅Vim's change.txt 帮助文件中的第 3 节。

【讨论】:

  • 在实验中,看起来g~<motion> 也有效。可能要补充一点,我倾向于专门使用~
  • 这意味着我们可以使用gUiw将一个单词变成大写。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-04
  • 1970-01-01
  • 2011-08-01
  • 1970-01-01
  • 2023-02-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多