Why do some Vim mappings include after a colon?

That isn’t part of the syntax for the onoremap command, that is explaining what a particular mapping does. That mapping is:

onoremap <silent> F :<C-U>normal! 0f(hviw<CR>

So, when the F key is used while an operator is pending vim will replace that with the bits in the next argument to the onoremap command. That starts with a : to begin an ex mode command. If there is a visual selection when the mapping is used, vim will automatically insert the range '<,'> so that the following ex command will apply to the visual selection, leaving the command line looking like:

:'<,'>

The <C-U> in the mapping tells vim that after the : is entered the Control+U combination should be used to clear the command line, eliminating the automatically inserted range leaving the command line looking like:

:

Then the remainder of the mapping is used.

You can see this for yourself by using V to begin a line-wise visual selection, then : to start entering a command. The range will show up, you can then use Control+U to clear it just as the example mapping does.

The portion of vim help that contains that mapping explains the remainder of it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)