I am a vim user.
I like to use CLI vim rather than GUI MacVim.
I usually use vim in iTerm2 terminal which has already a lot of shortcuts using Command Key.
I want to map my custom shortcuts but it's impossible because of those already mapped keys.
For example,
I want to map NERDTreeCommenterToggle command to 'Command-/'.
So I wrote in my .vimrc like below.
map <D-/> <Plug>NERDCommenterToggle
But it doesn't work because "D-/" key is already mapped to 'Find Cursor' in iTerm2.
Does anybody know how to fix these problems? Thanks in advance.
No.
It's impossible to map the command key in CLI Vim because the only Vim that supports it is MacVim in its GUI form. Whether iTerm uses up all the Cmd+… shortcuts or not is irrelevant.
You must find other keys, preferably some that work everywhere (CLI, GUI, Mac, Win, Linux).
:h mapleader is a good start.
Related
I am using Ubuntu now.
I used vundle installed bufexplorer and vim-buffergator plugin for vim. But when I type ¥be or ¥b, the <Leader> key ¥ not working in the vim editor. Is it necessary to set something in the ~/.vimrc file?
I didn't meet this problem until now, even I used Ubuntu or CentOS before.
Check out whether the mappings have actually been defined via:
:verbose nmap <Leader>b
This will also show what key the <Leader> key is configured to. If there's no output, check whether the plugin has been correctly installed (output of :scriptnames lists the plugin script, commands like :BufExplorer are available, etc.)
vim-buffergator explanation mentioned conflict with bufexplorer.
From https://github.com/jeetsukumaran/vim-buffergator :
[NOTE: If you have other plugins installed that have key maps that start with "<Leader>b" (e.g., BufExplorer, which uses "<Leader>bs", "<Leader>bv", etc.), then you may notice a slight delay or lag when typing the default "<Leader>b" to start Buffergator. In this case, you should either use another keymap for Buffergator or BufExplorer.]
I realize this may be a small thing, but I enjoy being able to quickly switch between current tabs this way. I'm basically looking for how to put this in my .vimrc file. I've edited key bindings plenty for Sublime Text but not for Vim.
I'm using iTerm as the GUI.
Thanks for any davice!
You can't do that in CLI Vim because:
it doesn't understand multiple modifier keys
it doesn't understand the ⌘ key anyway (only MacVim does and only in its GUI incarnation)
But you can create custom shortcuts in iTerm itself that send raw characters to the terminal.
Anyway, the default gt and gT are far better, buit-in and guaranteed to work everywhere. What is the most important weapon in your arsenal? Vim or Chrome? Get used to Vim's way or you'll never rip any benefit.
Vim using <c-6> to switch alternative file is not functional on Mac terminal while MacVim works.
The current version of Vim is 7.3.
To switch to the alternate file you can use control-shift-6 (<C-^>) or :e #. Both of these work in the Terminal.
Take a look at :h CTRL-^
It's not possible to map <C-#> in terminal mode. It's a limitation of terminals that they can't handle most Ctrl key combinations. The only ones that work are A-Z and just a couple others. Similarly, you can't detect combinations like Ctrl+Shift+a; they just come through as <C-a>.
You'll either have to remap the key to something else, or configure your terminal emulator to send a different key combination when you press that. Either way, you'd have to configure your Vim to accept something other than <C-6> when using a terminal.
I am trying to use the command button in MacVim instead of Ctrl and other buttons.
I tried something like :imap <D-space> <Esc> to override the normal Command-space functionality while in MacVim but it still performs the spotlight.
Any ideas?
In these cases its usually the window manager intercepting the key-stroke before the application ever sees it. There may be an option to turn off certain global key-bindings when a specified app is active but I've been unable to find it on 10.5 - linux window managers have this functionality, as does windows, so I'd expect its hiding somewhere in the OS WM..
The Spotlight shortcut takes precedence over your own shortcut.
To be able to use it in MacVim you must change Spotlight's shortcut in its preferences.
However, the Command key won't work in Terminal.app and won't be sent to remote servers connected by SSH. If you use Vim on a server you won't be able to use it and you will be forced to either create and learn lots of machine-specific mappings or simply use the defaults.
Another possible issue, one I encountered at the beginning, is that shortcuts with multiple modifier keys (like <D-M-something> or <C-S-something>) don't work in MacVim.
Because of that and the number of native shortcuts using these keys you won't have many possibilities.
When I decided to learn Vim (with MacVim), I tried a lot of things to make it (and Vim) more "Mac-like" or "TextMate-like" to no avail.
Instead i suggest you to do things the Vim way. It may seem weird but it's worth it.
In your case, the "Vim way" would be to use mapleader, it's a regular key on your keyboard that is used for custom mappings. The default key is \, if you want to change it (to , for the example, that's my settings but YMMV), add this line to your ~/.vimrc:
let mapleader=","
After that you can create mappings like this:
inoremap <leader><Space> <ESC>
My job involves working on Windows, *ix and with variety of IDE's like Eclipse, Visual Studio. Sometimes I really don't want to open Eclipse for little editing so I would prefer simple text editor like Vim, but the keys for the commands are horrible to me, I would like to setup Vim command keys to simple and modern style.
Can someone guide me how to configure Vim commands to simple keys like Ctrl+C or Ctrl+V for copy paste (through clipboard) or Shift+→, Shift+← for selecting text.
See this question: How do I configure VIM for using Ctrl-C Ctrl-V as copy paste to and from system buffer in ubuntu?
and the over all help on how to do key mapping here: How to make a keymap
It's not the answer you're looking for, but I'm with hammar. For example the Mac version of vim has the standard Mac-style copy/paste shortcut keys "baked in" yet I use the default vim keybindings now, since, like yourself, I hop about Linux/Windows/Mac, and having the same vim keyboard shortcuts.
Conversely, you'll find managing your personalized, if unorthodox, key bindings more onerous than simply "going vim."
I presume you've "worked" the vimtutor?