Reputation: 308
I'm trying to map all the function keys to the corresponding symbols. This is what I have put in my .vimrc:
:noremap! <F1> !
:noremap <F1> !
:noremap! <F2> @
:noremap <F2> @
:noremap! <F3> #
:noremap <F3> #
:noremap! <F4> $
:noremap <F4> $
:noremap! <F5> %
:noremap <F5> %
:noremap! <F6> ^
:noremap <F6> ^
:noremap! <F7> &
:noremap <F7> &
:noremap! <F8> *
:noremap <F8> *
:noremap! <F9> (
:noremap <F9> (
:noremap! <F10> )
:noremap <F10> )
:noremap! <F11> _
:noremap <F11> _
:noremap! <F12> +
:noremap <F12> +
Although it works with the insert, command-line and replace modes it does not work e.g with the r,f and t commands. There appears to be no conflict when I check with the :map command.
Upvotes: 0
Views: 461
Reputation: 7128
As Johnmastroberti pointed out, indeed you need to use lmap to achieve your goal.
The CTRL-^
trick actually controls iminsert variable. You can set it manually with
:set iminsert=1
But the problem you can struggle with is clever-f plugin as it replaces default f
behaviour and (I can be wrong here but didn't find such option) do not allow to use lmapping.
Upvotes: 2
Reputation: 847
The vim help for f
reads
f{char} To [count]'th occurrence of {char} to the right. The
cursor is placed on {char} |inclusive|.
{char} can be entered as a digraph |digraph-arg|.
When 'encoding' is set to Unicode, composing
characters may be used, see |utf-8-char-arg|.
|:lmap| mappings apply to {char}. The CTRL-^ command
in Insert mode can be used to switch this on/off
|i_CTRL-^|.
Based on this, I think you would need to also do
:lnoremap <F1> !
:lnoremap <F2> @
" etc
I also found that I had to use CTRL-^
in insert mode as the manual suggests before the mappings would apply to f
and t
(the default was to ignore the lmap
ings).
Upvotes: 2