10

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

Community
  • 1
  • 1
greduan
  • 4,770
  • 6
  • 45
  • 73

2 Answers2

16

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.

Chris Johnsen
  • 214,407
  • 26
  • 209
  • 186
  • I tried it, but for some reason it does not work. I posted in the OP what I've tried. Thanks! – greduan Nov 18 '12 at 13:30
  • 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). – Chris Johnsen Nov 18 '12 at 20:04
  • 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')` – greduan Nov 18 '12 at 20:59
  • 1
    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). – Chris Johnsen Nov 18 '12 at 21:10
  • While you are learning to do without Command-s, you might also want to `nnoremap `; otherwise Command-s in normal mode seems to be treated like plain `s` (which works like `cl`: change character(s) to the right). – Chris Johnsen Nov 18 '12 at 21:37
  • I know totally what you mean @ChrisJohnsen I did consider that, but I'm gonna bear with it in order to remind me. ;) – greduan Nov 18 '12 at 21:51
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…

romainl
  • 186,200
  • 21
  • 280
  • 313
  • 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. – greduan Nov 18 '12 at 13:31
  • 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… – romainl Nov 18 '12 at 13:39
  • 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. :) – greduan Nov 18 '12 at 13:45
  • Try `:color desert`, it's easy on the eyes even in a 16 colors terminal. – romainl Nov 18 '12 at 14:21
  • Well, as soon as I tried using `vim` in Terminal, I got a Python error, do you know what could be the problem? I added info to the OP. – greduan Nov 18 '12 at 15:32
  • 1
    This is matter for another question. – romainl Nov 18 '12 at 15:56
  • True, I created a question for it: http://stackoverflow.com/questions/13441820/when-i-try-to-run-vim-in-command-line-i-get-python-errors – greduan Nov 18 '12 at 16:06
  • Eh, I think another advantage MacVim has is different cursor styles for different modes. It's a small detail but I always notice its absence in Terminal vim. Were there a way to have those cursor styles in Terminal vim, I'd probably use it exclusively. – Chris Vincent Jun 17 '16 at 21:33