0

When I use 5<C-w>> in vim it makes my currently selected split increase by '5'. When I try to create this mapping on my Mac:

noremap <silent> <D-S-Left> 5<C-w><<CR>
noremap <silent> <D-S-Right> 5<C-w>><CR>

... it does not work when I type command+shift+right. What am I doing wrong?

Edit: for clarity, I am using iTerm on a mac, and I have tried both control (<C-*>) and command (<D-*>), and neither work.

5
  • 1
    A first resource you might want to read is how to debug a mapping and then edit your question with your findings. However to save you some time: if you are using the terminal app (and not macvim) you won't be able to remap Command – statox Jun 15 '20 at 15:26
  • 1
    Also what you are referring to as a "tab" is called a "window" in Vim, or a "split window" I edited your question to make that clearer – statox Jun 15 '20 at 15:30
  • 1
    Thanks for the suggestions @statox. Working through the debugging suggestions I see that it was tmux that was disrupting things. I'll have to rethink working with both vim and tmux. – Magnus Jun 15 '20 at 15:42
  • 2
    If you found the problem don't hesitate to answer your own question: it could be useful for a future user. About vim+tmux they usually work pretty well, this is a common setup both on Linux and MacOS, so maybe you want to think more clearly about your leaders (tmux's prefix and vim's leader). I have found that using ctrl+space as the tmux prefix and space as the vim leader is a great combination which doesn't interfere with common OS features (at least on Linux but I don't see a reason why it wouldn't work well on Mac). – statox Jun 15 '20 at 15:45
  • 1
    @statox those are exactly my leaders on both an 8yo and a new macbook. Works fine in terminal.app and alacritty. – D. Ben Knoble Jun 16 '20 at 13:32
1

I think D- mappings only work in Macvim, but you can map it in iTerm2 by sending hex key codes (which is a slightly tedious process).

  • In iTerm, go to Preferences -> Profiles -> Keys, and hit + to add a new mapping
  • Record your Keyboard Shortcut
  • Choose Send Hex Codes option and define your vim mappings in hex key codes.

To find out the hex key codes you can use the xxd tool which you should be having by default. Note that you have to hit C-v C-w to input C-w (just like you would do in vim), same method for any special character.

Just for reference in my system, these were the hex key codes for each of the vim mappings you would need -

3517 3e   (5<C-w>> increase window width 5 times)
3517 3c   (5<C-w>< decrease window width 5 times)
3517 2b   (5<C-w>+ increase window height 5 times)
3517 2d   (5<C-w>- decrease window height 5 times)

Also note that you can export your iTerm2 profile in case you want to source control them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.