11

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

2 Answers 2

17

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.

Sign up to request clarification or add additional context in comments.

6 Comments

I tried it, but for some reason it does not work. I posted in the OP what I've tried. Thanks!
Are you sure you put the entries in your .gvimrc (g for GUI), not your .vimrc? They will only work in .gvimrc (and they do work for me).
I didn't put them in my .gvimrc, I put them in my .vimrc, however I did enclose it within if has('gui_running'), and inside that if has('gui_macvim')
They must be in .gvimrc; using has('gui_running') is not an effective substitute. The problem is that .vimrc runs before menu.vim where the defaults are assigned (any “overrides” done in .vimrc will be undone by menu.vim); .gvimrc runs after menu.vim (any overrides done there will not be undone; .gvimrc is basically the last init file to be processed).
While you are learning to do without Command-s, you might also want to nnoremap <D-s> <nop>; otherwise Command-s in normal mode seems to be treated like plain s (which works like cl: change character(s) to the right).
|
0

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…

8 Comments

I think I'll do that, one reason I didn't is because all my color schemes act really strange with the Terminal, I've tried all sorts of stuff, but doesn't work. I think I'll just train myself to not use shortcuts, unless the question below works.
Don't worry about colorschemes: the default ones work just as well as the cool ones. Focus on the core parts instead: Ex commands, text objects, motions, macros, substitutions…
See, the problem is, even the default one looks strange. And I think you can agree that without a color scheme it's kind of hard to code. But, nevertheless, I'm gonna try to fix it, solve it, and follow your tips. :)
Try :color desert, it's easy on the eyes even in a 16 colors terminal.
This is matter for another question.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.