Keep It Simple Stupid

Uppercase replaced text in vim

| comments

I tell you what, vim is no doubts an awesome text editor! You can do tons of stuff with it very fast. This post is a quick note how to make some text uppercase in the search-replace command.

An example first. Suppose we have a list in markdown (and it’s much much longer):

* Item 1
* Awesome list item 2
* The end

and we need to uppercase the first word of each item’s title. As we have a lot of these lines, the manual job of uppercasing is very boring and monotonous. Besides, any true programmer/admin/geek strives to automate everything she can. Thus, typing :%s/^\* \(\w\+\)/* \U\1/g will do the trick:

* ITEM 1
* AWESOME list item 2
* THE end

The key part here is the usage of \U modifier in the replace string, which will uppercase all the text that’s followed to the end of line or until \E. To find out more type :h sub-replace-special.


Don't hesitate to leave a comment below. NB! If you don't see a comment form under the post, it's most likely that an extension (such as Ghostery, NoScript, or AdBlock) of your browser blocks the scripts from, and you can unblock that.

« Git SSH Keys on Windows jmp »