Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In another thread this terrific mapping was suggested as a way to upper-case SQL keywords:

noremap <leader>s <Esc>:s/\v<select>\|<from>\|<insert>\|<into>\|<table>\|<where>\|<delete>\|<limit>\|<order>\|<by>\|<asc>\|<desc>\|<set>\|<update>/\U\0/g<Return>

However, it appears that <insert> and <delete> are VIM keywords. How does one escape them? The obvious attempt to precede them with \ does not work!


share|improve this question
You could drop the "very magic" \v at the beginning and escape all the <> with backslashes. – romainl Oct 26 '12 at 15:06
Thank you, that ties in with the mention of "very magic" in the other thread. I also had to double up the `` escape characters on the pipes as well. Please post your comment as an answer so that I could accept it. Thanks! – dotancohen Oct 26 '12 at 15:21
up vote 3 down vote accepted

Yes, escaping the angle brackets is probably the right way to go.

My original proposal used \v to reduce the number of backslashes in the search pattern but it didn't take into account the requirements of mapping.

The solution is thus to remove the \v and go into backslash frenzy to end up with something like:

nnoremap <F9> :s/\<insert\>\\|\<delete\>/\U\0<cr>
share|improve this answer
Thank you Romainl! Always good to learn from you! – dotancohen Oct 26 '12 at 15:46

In this case, since that occurs in a regular expression you can get around that problem by breaking up those sequences by using grouping to share the <> characters:

noremap <leader>s <Esc>:s/\v<(select\|from\|insert\|into\|table\|where\|delete\|limit\|order\|by\|asc\|desc\|set\|update)>/\U\0/g<Return>

More generally, you could replace the < characters (either all of them or just the ones before the problem words) with <Char-0x3c>, 0x3c being the ASCII value for the < character.

share|improve this answer
Very cool, thank you! There are so many ways to fry eggs with VIM! – dotancohen Oct 26 '12 at 15:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.