如何在Vim中将单词的首字母大写? [英] How do I capitalize the first letter of a word in Vim?

查看:145
本文介绍了如何在Vim中将单词的首字母大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长时间以来,我就知道可以在Vim中使用来切换字符的大小写.但是,是否有一种方法可以映射一个键以大写一个单词并返回到先前的位置?

For a long time I've known that I can use ~ in Vim to toggle the case of a character. But is there a way to map a key to capitalize a word and go back to the previous position?

例如:

I like to drink Coca co[l]

如果我的光标位于"l"并且我意识到我也需要将"c"大写,那么我现在需要做:

If my cursor is at "l" and I realize I need to make the "c" capitalize as well, currently, I need to do:

<C-c> b ~ ll i

有没有办法映射单个键以使光标下的单词的首字母大写并将光标保持在原始位置?

Is there a way to map a single key to make the first letter of the word under cursor to be capitalized and keep the cursor at original position?

推荐答案

:nmap <whatever> m`b~``

这篇关于如何在Vim中将单词的首字母大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆