1

I had a previous problem that was solved, but it seems I am stuck once again.

I'm trying to reassign the keys for switching between Windows to be more intuitive. I've found that you should be able to add the following to your vimrc:

nmap <D-Right> :maca _cycleWindowsBackwards:<CR> 
nmap <D-Left> :maca _cycleWindows:<CR>

Which I've tried but it does not seem to do anything for me. My vimrc is definitely being loaded as when I enter bogus I get an error when starting vim.

I've tried different variations of assigning keys, with none really seeming to do anything.

Also, what is the recommended resource for VIM documentation?

Naatan
  • 1,415
  • 2
  • 14
  • 13

4 Answers4

4

The simplest way is the best way:

nmap <D-Right> <C-w>l
nmap <D-Left> <C-w>h

This answers your question but I don't advise you to go that way.

The first problem you'll encounter is that all of your cmdsomething mappings are going to fail in the terminal.

The second is that MacVim doesn't support multiple modifiers: you won't be able to have CtrlShiftb, for example. Well, it will work but the Shift part will be ignored so you will be limited very quicly.

The third problem will be that you'll fail to commit Vim's commands to memory. The day you'll ssh into a server and use Vim there you'll be lost.

So yeah, you CAN do that but (I think that) you SHOULDN'T.

Instead, learn the Vim way and type :help windows. It will pay. Quickly.

romainl
  • 23,415
1

I have no idea where you got the ":maca" command, but it is not a Vim command. Also, what is "_cycleWindowsBackwards:" and "_cycleWindows:"?

I suspect what you really want is something more like this:

:nmap <D-Right> :wincmd W<CR>
:nmap <D-Left> :wincmd w<CR>
Heptite
  • 20,411
1

Just gone through all this myself. Quickest and easiest solution on a Mac I've found is: http://pqrs.org/macosx/keyremap4macbook/document.html

This utility will allow you to change your Command keys. You may also set up profiles (I set up a VIM profile) so that I just turn on my VIM profile only when in VIM (quick toggle on menu bar) so it doesn't mess anything (mac osx behaviour, utilities or applications) else up.

I'm on a Macbook Pro so I wanted to change my option keys to control keys while in VIM. This utiltiy allowed me to do that and I also changed my fn key to option just in case.

They also have another utility: http://pqrs.org/macosx/keyremap4macbook/extra.html

Which allowed me to change my Caps Lock key to be Esc. Which is FANTASTIC in VIM; no more reaching for Esc constantly. Note: this utility doesn't have the profiles, so my caps lock is always Esc whether in vim or not.

0

Just a heads up in case others have a similar issue.

I had trouble mapping Ctrl+space in macOS (Sonoma 14.4.1) with;

map <C-@> :call ToggleTodo()<CR>

Turns out when reinstalling macOS on new laptop, a default shortcut for Ctrl+Space is now set in System Settings. This swallows the key combo and it fails to arrive at the Terminal app

You can disable this shortcut in System Settings under;

Keyboard -> Customise Modifier Keys -> Input Sources
Matt
  • 1