-1

i've added to my vimrc the possibility to move lines (on visual, on normal and insert mode) in file with alt+j or alt+k and it's working as expected.

in my .vimrc

nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv

My problem :

in insert mode : if I enter "ê" i have the lines on top my cursor that are getting deleted.

If i look at my vim mappings(:map) i can find the following lines:

v ë     * :m '<-2<CR>gv=gv
v ê     * :m '>+1<CR>gv=gv
n ë     * :m .-2<CR>==
n ê     * :m .+1<CR>==

My question:

  1. How is it possible that the mapping to move lines which involve alt, j, k creates a mapping for ë and ê.
  2. How can avoid to have ê and ë to be mapped as they are ?

thank you.

toshi
  • 556
  • 1
  • 4
  • 8

1 Answers1

0

Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. Same for Alt+letter, which are identical to upper 8-bit ASCII characters like ë. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.

Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8

But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

TL;DR: Change your (insert mode) mappings, e.g. to <C-G>j.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324