nightire
nightire

Reputation: 1371

Vim's key mapping behaving differently between gui mode and cli mode

I've been trying to figure this out for so long but still failed, some of my customized key-mapping (majority of them are for plugins) behaves totally different between gui-mode and cli-mode, even if I use gui-mode command with -v flag (like mvim -v) or using :gui command in terminal Vi.

For example, the Emmet plugin which is handy for expanding HTML/CSS expressions, the default trigger key <C-y> never works at first (in Cli-mode which I often used to), I always don't know why, until one day I use MacVim for a while and suddenly find out it works!

After that, I try to re-map the default trigger from <C-y> to <C-e> or <C-k>, both of them works fine in MacVim but still unlucky in terminal Vim.

Is there any particular reason to cause this issue? Maybe something wrong with my configuration?

Any suggestion will be appreciated, thanks!

Upvotes: 1

Views: 117

Answers (1)

nightire
nightire

Reputation: 1371

Finally I solved it by myself, but thank for @ebenezer 's reminding.

We often use set timeoutlen and set ttimeoutlen to tweak the latency for a key code or a mapping sequence to complete. Most of us can't tolerate with the default value for ttimeoutlen (which is -1), because it forces us to waiting for so long when quit from Insert mode by press ESC or Ctrl-[.

For this particular reason, I changed this value to 10 (in ms), but I copy this setting from somewhere I don't remember now, and it place set ttimeoutlen in a autocmd for all filetypes, like below:

if ! has('gui_running')
  set ttimeoutlen=10
  autocmd InsertEnter * set timeoutlen=0
  autocmd InsertLeave * set timeoutlen=1000
endif

I don't know why this will make some plugins not work properly, and I change it a little to make it works for me now:

if ! has('gui_running')
  autocmd InsertEnter * set ttimeoutlen=100
  autocmd InsertLeave * set ttimeoutlen=-1
endif

Hope this will help you if you encounter same problems.

Upvotes: 1

Related Questions