Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I capitalize the first letter of a word in Vim?

Tags:

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?

For example:

I like to drink Coca co[l] 

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?

like image 634
Patrick Avatar asked Jun 27 '10 05:06

Patrick


1 Answers

:nmap <whatever> m`b~`` 
like image 115
Ignacio Vazquez-Abrams Avatar answered Oct 10 '22 14:10

Ignacio Vazquez-Abrams