Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable use of MacVim keyboard shortcuts

Is there any way to disable keyboard shortcuts in MacVim? I mean the shortcuts like Cmd + s for example, I want to convince myself to use things like :w, but I can't do so if I can save the file using Cmd + s, you get me?

But I of course, still want to use the GUI, so is there any way to disable these, without stoping using the MacVim GUI?

Thanks for your help. BTW I made a Google search and wasn't able to find an answer.

EDIT:
Following @ChrisJohnsen's suggestion, I have already tried the following with no success:

if has('gui_running')
    macmenu File.Save key=<nop>
    macmenu File.Save\ As\.\.\. key=<nop>
endif

EDIT 2:
I moved the error I'm getting over to this other question: When I try to run vim in command line I get Python errors

like image 509
greduan Avatar asked Nov 18 '12 02:11

greduan


People also ask

How do you disable a shortcut?

Select “Keyboard” from the list on the left side of your screen. Click on “Shortcuts” in the list of settings across the top of the window. Once inside “Shortcuts,” uncheck the box next to each shortcut to disable it.

How do I turn off shortcut keys in Linux?

Find the shortcut you're trying to disable, click on it to set a new shortcut, then pressing Backspace will disable that shortcut.

What does shift 8 do in Vim?

Some other cool Vim search tips/tricks To start off, if you want to search for a word that's there in the file, but you don't want to type it, you can just bring your cursor below it and press * (or shift+8).


2 Answers

There is no simple way to disable all of the pre-defined Mac-style keyboard shortcuts, but you can definitely change/disable any of them. The important command is :macmenu (see :help :macmenu); it lets you set the Mac-specific properties of any Vim menu item (mostly Mac-specific keyboard shortcuts and Mac-specific actions (e.g. open/save dialog boxes, window manipulations, etc.)).

macmenu File.Save key=<nop>
macmenu File.Save\ All key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>

The thing is that :macmenu commands are only effective if they are in your .gvimrc file.

If you do :e $VIMRUNTIME/menu.vim and search for macm, you will find the list of pre-defined shortcuts and actions. Copy the desired lines to you .gvimrc and replace key=<whatever> with key=<nop>. You can also wrap them in if has("gui_macvim") / endif if you need your .gvimrc to work on multiple platforms.

like image 68
Chris Johnsen Avatar answered Oct 25 '22 19:10

Chris Johnsen


MacVim has only one "advantage" over plain Vim: it supports native Mac OS X shortcuts. If you don't want those shortcuts you might as well simply use plain Vim.

FWIW, when I switched from TextMate I, too, found after a while that these native shortcuts were an obstacle on my way to learning Vim. My solution was to focus my efforts on plain Vim. After a week in the terminal you should be able to completely disregard those shortcuts.

I'd advise you to take a little pause and think about doing things in a more appropriate order:

  1. In the terminal, do $ vimtutor as many times as needed.

  2. In the terminal again, use $ vim for simple tasks first then more complex tasks. There's a predictable productivity hit at the beginning but it will last only a few days/weeks.

  3. Once you have reached your previous level of productivity, you can start to fly Vim full-time. At that point, using MacVim or GVim or plain $ vim should make no difference whatsoever.

Bonus points for not relying too much on plugins, other people's vimrcs or "distributions" like janus or spf13…

like image 43
romainl Avatar answered Oct 25 '22 19:10

romainl