Saturday, June 9, 2018

How to insert text   on current text position when I press key in vim in insert and normal mode?

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&nbsp;\<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.

I use vim version 7.4 from CentOS 7.5

--
Best regards,
Gena

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: