On Mon, Jun 11, 2018 at 9:57 PM, Christian Brabandt <cbli...@256bit.org> wrote: > > On Sa, 09 Jun 2018, Gena Makhomed wrote: > >> Hello, All! >> >> How to insert text on current text position >> when I press <F1> key in vim in insert and normal mode? >> >> I try to use macros, and put in .vimrc: >> >> let @n = "i \<esc>" >> >> then I switch no normal mode - I can run this macro by pressing @n >> but how to bind this macro to <F1> key in normal and insert mode? >> >> I try to use in .vimrc: >> >> imap <F1> <esc>@n<cr>a >> nmap <F1> @n<cr> >> >> and >> >> inoremap <F1> <esc>@n<cr>a >> nnoremap <F1> @n<cr> >> >> but this is not work. >> >> When I write function: >> >> function InsertNbsp() >> normal @n >> endfunction >> >> and when I call this function >> >> :call InsertNbsp() >> >> this work, >> but when I try to bind this function to <F1> key: >> >> inoremap <F1> <esc>:call InsertNbsp()<cr>a >> nnoremap <F1> :call InsertNbsp()<cr> >> >> - it not work. > > > something like this, if your register contains ' ': > > :let @n=' ' > :inoremap <F1> <c-r>n > :nmap <f1> a<f1><esc> > > > Note that I would not recommend mapping <f1> > > Best, > Christian
Neither would I, because in Vim like in most other programs, F1 brings you to the first page of help. Gena: What's wrong with Ctrl-R n (in Insert mode) or "np (in Normal mode)? Or if you're dead set on using only one keystroke, any F key other than F1 (Help) and F10 (Menu) or any Shift-F key, would IMHO be better than F1. Best regards, Tony. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.