1

imap command does not work for me as expected in Vim. I place

inoremap <F2> abcde

in my .vimrc file, but when I press the F2 button in the insert mode, all I get is the <F2> symbol appearing in the text file, just as typed here, with brackets.

Testing it with :verbose imap <F2>? gives

i  <F2>        * abcde<Space>

At the same time I have a mapping for the normal mode in Vim:

nnoremap <F2> i\[<CR><CR>\] <Esc>ki<Space><Space>

and it works just as expected! (I use it to type multi-line formulas in LaTeX, \[ \]).

Since the mapping works in the normal mode, I do not think that this is the problem with unusual interpretation of the function keys on in my terminal.

Substituting F2 with F3, F4, etc does not help.

Tested: xfce4-terminal; plain xterm; console. System: Linux Mint.

Would appreciate your help very much!!

1 Answer 1

4

Check if it happens with vim -Nu NONE.

I suspect that you have set paste in your configuration.

If it is, unset it and check if your mapping would work.

Excerpt from :h 'paste'

'paste'         boolean (default off)
                global
    Put Vim in Paste mode.
    ...
    When the 'paste' option is switched on (also when it was already on):
        - mapping in Insert mode and Command-line mode is disabled
        - abbreviations are disabled
        - 'autoindent' is reset
        - 'expandtab' is reset
        - 'hkmap' is reset
        - 'revins' is reset
        - 'ruler' is reset
        - 'showmatch' is reset
        - 'smarttab' is reset
        - 'softtabstop' is set to 0
        - 'textwidth' is set to 0
        - 'wrapmargin' is set to 0
        - 'varsofttabstop' is made empty
    These options keep their value, but their effect is disabled:
        - 'cindent'
        - 'formatoptions' is used like it is empty
        - 'indentexpr'
        - 'lisp'
        - 'smartindent'
    .....
2
  • 1
    Maxim, thank you so so much!!!!!! I spend hours and hours on this... I should have asked earlier...
    – Maxim
    Jan 4 at 5:55
  • 2nd update: Ultisnips and vim-snippets started working, finally!! I gave up years ago... (Completion was not working, which is in insert mode, too) -- Thank you so much again!!
    – Maxim
    Jan 4 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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