StevieD
StevieD

Reputation: 7443

Temporarily disable keymap in vim

I've got the following keymap in vim:

inoremap { { }<Esc><BS>i<CR><CR><Esc>ki<Space><Space>

If I want to type a literal { without the other characters, how can I do it?

Upvotes: 1

Views: 420

Answers (2)

Luc Hermitte
Luc Hermitte

Reputation: 32966

Note also that there exist several brackets oriented plugins that detect the context in order to not expand things like { in comments or string contexts. lh-brackets, that I'm maintaining, also has a enabled/disabled feature, toggled on the trigger key.

Otherwise, for the punctual disabling that doesn't match recognisable contexts there is CTRL-V as ffledgling has told you.

NB: the idea behind context detection is to match the result of synIDattr(synID(line('.'),col('.')-1,1),'name') against 'comment\|string\|character\|doxygen' (see lh#map#*context*() functions in lh-brackets), and have your map-<expr> expand to either { or {} + cursor movement that doesn't break redo + other things possibly.

Upvotes: 2

ffledgling
ffledgling

Reputation: 12170

The way to enter a literal character in vim is to use Ctrl-V.

In your case, when in insert mode, you'd type Ctrl-V followed by {

Upvotes: 3

Related Questions