简体   繁体   中英

Vim function won't respond in terminal vim

I stumbled upon a function that is similar to a feature in Textmate.

That displays the highlighting groups for the current word.

Everything works perfectly in gvim,but won't get an output when using vim, which leaves me puzzled.

Here is the relevant part:

nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
  if !exists("*synstack")
    return
  endif
  echo map(synstack(line('.'), col('.')), 
  \       'synIDattr(v:val, "name")')
endfunc$

My question is why it behaves like this and how to fix it, if possible -.-

I appreciate any help that one can provide.

The problem was this line:

nmap <C-S-P> :call <SID>SynStack()<CR>

which asks vim to map c ontrol s hift p to the SynStack macro. However, terminals such as xterm, which ultimately use ASCII characters and ECMA-48 control sequences have no way to treat these as distinct:

  • c ontrol s hift P
  • c ontrol s hift p
  • c ontrol P
  • c ontrol p

They all come in as control P (ignoring case). gvim works in a different environment, where most combinations of modifiers can be distinguished from each other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM