TransWikia.com

Is there a way to map (Alt - Shift - Control - Any key) in vimrc?

Vi and Vim Asked by Dylan Plummer on August 31, 2021

The ergodox keyboard I use has two dedicated modifier keys ( Alt – Shift – Ctrl ) and
( Alt – Shift – Ctrl – Windows)

I would like to use the modifiers in my vimrc to do more specific tasks.

nnoremap <A-S-C-P> ihello

Was my initial test, it did not seem to work, however I didn’t find too many example of multiple modifier keys in vim.

Is this possible/is there a better way to do this?

One Answer

It depends:

  • If this is terminal-bound Vim (i.e. the good old traditional way) then it will only work if the terminal type you're using has a way to encode multiple modifier keys when delivering them through curses to Vim.

    The most common sort of terminal can't do that, so chances are excellent that this is what's causing your symptom.

  • GUI Vim front-ends will usually get you around this problem because the operating system's GUI layer does have a way to pass multiple modifier keys down to the GUI Vim front end, and it will pass them down to Vim.

    In this case, you can add a if has("gui_running") conditional around your map calls in your .vimrc file to create mappings intended to work only while under a GUI version of Vim. I will usually create an alternate mapping in the "else" clause so I have another way to get the same function.

Correct answer by Warren Young on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP