I don't like to use the arrows to move the cursor, since they are somewhat out of reach. My idea is to maintain the control key down, and press the HJKL keys. Therefore, I prepared the following imap calls:
:imap <C-h> <Left>
:imap <C-j> <Down>
:imap <C-k> <Up>
:imap <C-l> <Right>
These mappings worked as expected. Then I decided to add a few erase operations. I thought it would be simple. The first two trials worked perfectly well:
:imap <C-x> <Delete>
:imap <C-z> <BS>
However, I would like to have the command mode X, that erases the character before the cursor. I tried:
:imap <C-X> <BS>
It seems that vim considers <C-x> and <C-X> to be the same key. Of course, <C-X> is pretty tough to press, but I would like to keep it for symmetry.
My question is: How to make insertion mode <C-X> work like normal mode X?
> My question is: How to make insertion mode <C-X> work like normal mode X?
You seem not to know about insert mode control O. See
:h i_ctrl-O
So,
:inoremap <c-x> <c-o>X
Regards, John
Hi, Tim.
Your answer was very useful. Since I cannot use <C-S-X>, I mapped the backspace key to z. Although <C-z> is not symmetrical with the X command, it is more practical, since it is very difficult to press <C-S-X>. However, I am having another problem. I hope you can help me with it.
I am new to Vim, as you can see (five days of practice, to be exact). In any case, I wrote the following script, that worked perfectly well in the machine I am using to perform experiments:
:imap <C-h> <Left>
:imap <C-j> <Down>
:imap <C-k> <Up>
:imap <C-l> <Right>
:imap <C-x> <Delete>
:imap <C-z> <BS>
:imap <C-w> <C-o>:w<CR>
However, the script is not working in about 40 machines. The machines are all of the same brand (HP), and roughly the same model. All machines are running Zorin OS, that is built on top of Ubuntu. As far as I am aware, all machines have the following programs: Ubuntu, Zorin, konsole, rlwrap (that was necessary to run a shell inside vim), sbcl Common Lisp, Emacs, Latex, Latex-extra, vim, cream, firefox, google.
In the machines where the script does not work, when one types <C-x> in INSERTION mode, the command erases the char below the cursor, and put the cursor one char ahead, leaving a blank behind. In fewer words, the <C-x> command is behaving almost like a replace space bar.
Hi, Suresh.
Your script is exactly what I wanted all the time. Therefore, I don't have any work left. All I have to do is downloading your scripts, and start typing. However, I have a question. In the distribution of your mapping, there is a warning: "The contents may not be useful for Vim 7." What does it mean? The mapping may not work for Vim 7.3? I run a few test, and everything seems ok.
which is "a modern configuration" of vim, with "A single editing mode".
Now, having started with vi in 1983, cream is not for me, but appears to have all the mappings that the OP wanted, in a consistent, considered, and supported fashion.
Regards, John Little