Vim is available for many platforms, including Windows. Although it has a strong association with Unix, thanks to the heritage of vi, Vim was originally released on the Amiga (my favourite computer and OS of all time). Over the years Vim has been adapted to various systems and has platform-specific features. In this tutorial I'm going to introduce using Vim for Windows, and discuss a few Windows-specific options.
Download and Installation
To download Vim for Windows, go to Vim's site, select Downloads, then scroll down to PC: MS-DOS and MS-Windows. I usually download the gVim executable installer, which has several options -- make sure you click "Create .bat files for command line use" if you want to run Vim from with
Running gVim and Vim
Once Vim's installed, it can be started from the desktop or the start menu:
This provides some convenient shortcuts for pretty much everything available in typical Unix installations, including Vim Diff and Vim tutor. Running gVim displays Vim inside a GUI, which is just like other GTK-based ports of gVim and similar to MacVim. To start console Vim, either type
vim.exe in Command Prompt, or run Vim from the start menu.
gVim and Vim running side-by-side in Windows
Files can be opened by typing
:e filename, but don't worry too much about typing the correct slash because Windows will internally map between forward and backslashes. Typing
:help will display the standard documentation and
:help win32 displays Windows-specific help.
Vim's split windows (
:help CTRL-W) can be manipulated using the mouse by default -- this includes dragging to resize. The "Window" menu in gVim provides an easy way to work with windows if you haven't learned the commands before.
:e $HOME\_vimrc to edit the current user's
vimrc -- note the underscore. As an example, let's disable the arrow keys to encourage ourselves to learn
hjkl for movement:
" Disable arrow keys inoremap
inoremap inoremap inoremap noremap noremap noremap noremap
Save the file and quit by typing
:wq. Now reopen Vim or gVim, enter Insert mode by pressing
i, type something, then try to move around with the arrow keys.
If you want to share your Vim configuration with a Unix system, you can add Windows-specific configuration options like this:
" Windows-specific settings if has('win32') " Windows gVim-specific settings if has('gui_running') endif endif
Finally, the ALT keys in gVim will map to the underscored letters in the menus. This is controlled by
menu is the default. When
menu is set, keys that are not currently mapped by a menu item can be mapped to custom commands. It can be turned off entirely by typing