Tuesday, June 12, 2018

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

On 12.06.2018 2:22, Tony Mechelynck wrote:

> On Mon, Jun 11, 2018 at 9:57 PM, Christian Brabandt wrote:

>> :let @n=' '
>> :inoremap <F1> <c-r>n
>> :nmap <f1> a<f1><esc>

Christian, thank you! All works fine now!

>> Note that I would not recommend mapping <f1>

Why not? <F1>, as I understand, is always mapped to vim :help command.
<F1> on keyboard located near <ESC> key, it is very useful to press <F1>

> Neither would I, because in Vim like in most other programs, F1 brings
> you to the first page of help.

And this is completely useless for me, I always can enter :help command
from keyboard. Even more, typing just three keys :h<CR> is enough.

It is more useful for me to read vim documentation via web-site,
for example, site http://vimdoc.sourceforge.net/htmldoc/help.html
contains documentation for vim 7.3, and I am use vim 7.4, it is Ok.

Web site http://vimdoc.sourceforge.net/htmldoc/help.html
was not updated from 2010 year - this is bug or feature?

> Gena: What's wrong with Ctrl-R n (in Insert mode) or "np (in Normal
> mode)?

wrong #1: it is different keys in different modes,
this is uncomfortable.

wrong #2: I need to press more when one key on the keyboard,
this is uncomfortable too.

wrong #3: I use vim to edit text written on Russian language,
and my keyboard frequently switched to Russian language layout.
If keyboard in Russian language mode - vim just beep and do nothing.

So, I need first switch keyboard from Russian to English,
when find in which mode vim is currently, and select appropriate
keyboard sequence, when enter this sequence on keyboard,
when switch keyboard back from English to Russian mode.

This is very uncomfortable for editing text.
Just pressing <F1> is very fast and very useful.

> 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.

I just don't want continually switch keyboard
from Russian to English and from English to Russian.

So, I can use only functional keys on keyboard or other
key combinations which are available in VT100 terminal mode.
(I use PuTTY, ssh and screen, so terminal is limited to VT100)

P.S.

One more question.

Is it possible with vim:

If I press <F1> and text under cursor is space - replace it with &nbsp;
If I press <F1> and text under cursor is not space - generate beep

I try to write this via function:

===========================================================

function SpaceReplace()
if getline(".")[col(".")-1] == ' '
echo "replace <space> under cursor with &nbsp;"
else
echo "beep"
endif
endfunction

inoremap <F1> <esc>:call SpaceReplace()<CR>a
nnoremap <F1> :call SpaceReplace()<CR>

===========================================================

But I can't understand what I need to write instead "echo".

--
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:

Post a Comment