It seems you were trying to use this mapping by pressing F5 from Normal mode, while the mapping you created is only valid for Insert mode.
You can duplicate this mapping so that it also works in Normal mode. If you do so, you should omit the <C-O>
part, since that's only needed to go back to Normal mode, for a single command, while you're in Insert mode. (See :help i_CTRL-O
for details on that command.)
(If you keep the <C-O>
in the Normal mode mapping, it will execute the Normal mode CTRL-O
command, which jumps back to the last cursor position in your jump list.)
inoremap <F5> <C-O>:set spell spelllang=en_gb<CR>
nnoremap <F5> :set spell spelllang=en_gb<CR>
Or you could just reuse the normal mode mapping from the Insert mode one:
nnoremap <F5> :set spell spelllang=en_gb<CR>
imap <F5> <C-O><F5>
In that case, the Insert mode mapping needs to be a recursive mapping (use imap
rather than inoremap
), in order to be able to use the other Normal mode mapping you created.
'spell'
and/or'spelllang'
more permanently, for instance in a filetype plugin (or even just in your_vimrc
), which means you'd generally not need to manually switch it on at all. – Rich Jul 8 '20 at 13:59inoremap
tonoremap
(did not know about this. But now all sorts of weird things happen. F5 and F6 seem to have their own functions in Normal mode. In any case, if you file an answer I am glad to accept it. – Luís de Sousa Jul 8 '20 at 14:16