tpope / vim-rsi

rsi.vim: Readline style insertion
http://www.vim.org/scripts/script.php?script_id=4359
581 stars 35 forks source link

Meta mappings not working when $TERM is not xterm #25

Open pablox-cl opened 9 years ago

pablox-cl commented 9 years ago

While I see vim-rsi is correctly mapping <M-d>:

:verbose imap <m-d>
i  ä           * <C-O>dw
        Last set from ~/.vim/.cache/neobundle/vim-rsi/plugin/rsi.vim

My $TERM/terminfo(?), prints ALT + D as ^]d, unsurprisingly typing the ä, results in the desired command. When running vim from an xterm, it correctly(?), maps ALT + D as ä.

It seems every other terminal emulator (rxvt, and almost everyone [if not all] based on the vte gtk widget) maps ALT + D as ^]d. Though, setting <M-d> as <esc>d, partially solves the problem:

execute "set <M-d>=\ed"
" I tried using \<Esc>, but it's too fast(?) and exists insert mode and let you in operator pending after inserting a `d`.

If I understand correctly, problem with that is that you use <M-d> fast enough (below ttimeoutlen?) the command gets executed as two: ^[, and d and you get out of insert mode and d is inserted in normal mode.

Anyway, I think a plausible workaround could be checking the term, and in case is not xterm, run that line. If you are interested I can do a PR.

justinmk commented 9 years ago

Did you try withvim -u NONE -N -c 'set rtp +=path/to/vim-rsi' -c 'runtime plugin/rsi.vim' ?

pablox-cl commented 9 years ago

Yep, it results in the same behaviour, why it could be useful?

Anyway, I still find this solution a bit erratic :/.