how to configure vim commands to windows style? - vim

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?

Related

IdeaVim : Navigate through project file

Is it possible with the plugin IdeaVim for IntelliJ to navigate thourgh project file (in the window below) using hjkl key ? Like the CtrlP plugin for Vim.
As of 2021, this is now possible.
All you have to do is enable the NERDTree plugin in ideavim by inserting set NERDTree into your .ideavimrc
if you're looking for a CtrlP equivalent, Webstorm has a fuzzy finder that's actually much more powerful than CtrlP.
Try COMMAND+SHIFT+O (the letter O) on Mac or CTRL+SHIFT+N on Windows/Linux.
There is more here: https://www.jetbrains.com/help/phpstorm/2016.1/navigating-to-class-file-or-symbol-by-name.html?origin=old_help#d937859e425
This is old but just in case anyone is looking for marginal efficiency. I use this AutoHotKey script to achieve this exact behavior - together with as you'll figure other mapping for never needing to travel out to the Numpad, Arrow keys or Special keys.
As it is a very short repo here are the essentials:
Download autohotkey (https://autohotkey.com/).
Place the .ahk script into the startup folder (win + r, then run "shell:startup" to find on Windows) (https://autohotkey.com/docs/FAQ.htm#Startup). This allows the script to always be active, as it is ran on startup.
Run the Script to go into effect now.
The script is:
#SingleInstance
+CapsLock::CapsLock
CapsLock::Esc
Its been game changing

Is there a way to switch between tabs in vim using `⌘ + ⌥` - `left or right` like Google Chrome or Sublime Text?

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.

Console editor: something between VIM and nano?

I used vim for a long time, but switched to Sublime Text last year for most of my programming work.
Now, every time I have to make use of a console editor (mostly over ssh), I feel extremely uncomfortable with vim. The shortcuts and commands have slowly left my memory, my once carefully curated vimrc is gathering dust, and I just can't use the editor effectively without re-learning everything.
On the other hand, nano is just dumb. Great for opening a file, adding a flag and closing it, but way too primitive for anything else.
Is there something in between I can use? I can settle for not-as-easy-as-nano-nor-as-powerful-as-vim.
You can use mcedit. It is much more user friendly than other editors - it even supports mouse over ssh (even in Putty console from Windows).
Simply install package Midnight Commander as follows:
Ubuntu/Debian:
sudo apt-get install mc
Fedora/Redhat:
sudo yum install mc
MacOS:
brew install mc
and it will make mcedit available.
In local console it even supports Shift+Del, Shift+Ins, Ctrl+Ins shortcuts that we use in Windows.
It also has nice ability to copy blocks into arbitrary files, effectively giving you unlimited number of clipboards.
You could try these, but you'll have to install them on the machines you SSH into:
joe
ne
diakonos
But my opinion is that you should drop the seriously underpowered Sublime and go back to Vim.
$ vimtutor is your friend.
If you want to learn a text editor that's available on just about every machine you could possibly SSH into, basically your only options are vim, emacs, nano, and ed.
Emacs is an okay choice, so long as you can remember c-x c-s (save) and c-x c-c (close)… But that's only two fewer commands than you need to remember with vim (i for insert mode, <esc> for normal mode, :w to save, and :q to quit).
Possibly a better alternative would be to run X11 locally, so you can use gedit, gvim, or one of the other graphical editors from the remote machine? Or maybe print off a couple of cheat sheets (see: https://stackoverflow.com/questions/442057/what-is-your-linux-vim-cheat-sheet) and keep them on your person at all times?
I haven't personally used it, but the Cream flavor of Vim modifies Vim with more standard-style mappings (e.g. CTRL-F for Find), no modal editing (normal vs. insert mode) as in Vi(m), and it also works in the console (with menus). Maybe that makes Vim suitable to you.
Since you're a Sublime user, you'll probably feel comfortable with Suplemon https://github.com/richrd/suplemon.
It's a bit like Sublime and it's specifically created to be easy and powerfull at the same time. It also has multiple cursors and similar key mapping as Sublime. It's written in Python and supports addon modules. Hopefully one day it'll support Sublime packages too.
Disclaimer: I'm the developer of Suplemon.

Is there a way to change vim's default mode

Does anyone know how to change vim's default mode? Its default mode is command mode, but could I change it to insert mode?
Just add the following line to your vimrc:
start
Vim's default mode will be changed to Insert mode. Just press Esc to enter Command mode.
You can try the 'insertmode' option (add set insertmode to your .vimrc file), although I recommend that you learn the standard vi operation, because not all vi-like editors support this mode of work.
cheers,
mitch
If you really want an editor that starts out in insert mode, perhaps vim is not the editor for you.
Most editors that aren't based on vi behave the way you want. Emacs is very powerful, but it may be too complicated for your needs. Nano (man nano for info nano for more information) might be a good choice. There are other possibilities.
vim really isn't designed to be used that way. As others have said, there are ways to force it to start up in insert mode. (I've been using vi-style editors for decades, and I didn't even know about :set insertmode until now.) But it's awkward to use.
My advice: either (1) use an editor that behaves the way you want, or (2) spend some time learning to use vim in its default configuration, and see if you can get used to it.
One big advantage of vim's separation of insert and command modes is that the command mode can use letters as commands; modeless editors generally have to use control keys or function keys to execute commands.
Update (a decade later): vim has an option -y that starts it with insertmode enabled. evim is equivalent to vim -y, and eview to view -y. From the man page (emphasis added):
eVim starts Vim and sets options to make it behave like a modeless editor. This is still Vim but used as a point-and-click editor. This feels a lot like using Notepad on MS-Windows. eVim will always run in the GUI, to enable the use of menus and toolbar.
Only to be used for people who really can't work with Vim in the normal way. Editing will be much less efficient.
The 'insertmode' option is set to be able to type text directly.
Mappings are setup to make Copy and Paste work with the MS-Windows keys. CTRL-X cuts text, CTRL-C copies text and CTRL-V pastes text. Use CTRL-Q to obtain the original meaning of CTRL-V.
You can use
vi -cstartinsert
or
vi -cstart
That launch vi and put it insert mode. You can do an alias to that if it's really usefull (I still understand why you want that anyway). You can also look at this tip.
"Cream" is a project that aims to make Vim easier to use. By default everything you do in Cream is in insert mode, I believe:
http://en.wikipedia.org/wiki/Cream_%28software%29

MacVim: Any idea why I can't override the Command button?

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>

Resources