AkshaiShah
AkshaiShah

Reputation: 5939

Inoremap not working

I'm trying to set up auto bracket inserts in vim, and have done the following:

:inoremap { {}<Left>

But, when I go to insert mode, and enter {, only the { is inserted as expected. I have checked :imap and it contains the following:

i  <S-Tab>     * <C-R>=BackwardsSnippet()<CR>
i  <Plug>SuperTabBackward & <C-R>=SuperTab('p')<CR>
i  <Plug>SuperTabForward & <C-R>=SuperTab('n')<CR>
i  <C-Tab>     * <Tab>
i  <Tab>       * <C-R>=TriggerSnippet()<CR>
i  <CR>        * <C-R>=<SNR>19_SelectCompletion(1)<CR>
i  <C-R><Tab>  * <C-R>=ShowAvailableSnips()<CR>
i  <C-X>         <C-R>=<SNR>19_ManualCompletionEnter()<CR>
i  {}          * {}
i  {{          * {
i  {<CR>       * {<CR>}<Esc>O
i  {           * {}<Left>

Which shows it is set up correctly. Anyone able to help?

Upvotes: 0

Views: 2644

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

It looks like the < value has been added to your 'cpoptions', so special key codes like <Left> don't work. Watch out for :set cpo commands or :set compatible (which also affects 'cpo') in your ~/.vimrc.

Also, don't :set paste in your ~/.vimrc:

When the 'paste' option is switched on (also when it was already on): - mapping in Insert mode and Command-line mode is disabled

Rather, define a key to toggle this:

:set pastetoggle=<F11>

Upvotes: 6

Related Questions