13

I am a frequent user of the Vim editor on Linux and now I want to use it on Windows.

I downloaded Vim for Windows, which happens to be gVim. Several features of Vim doesn't work in gVim 7.4 like visual block, rx command, and several other key combinations.

I want the same/original Vim from Linux to be used on Windows. Is that version available for Windows too? Or, can I use settings similar to the Unix format?

  • 2
    Try the Vim from tuxproject.de/projects/vim/x64 – muru Apr 21 '16 at 16:20
  • 6
    Also, check your _vimrc file for a line saying something like source $VIMRUNTIME/mswin.vim. That file enables lots of config stuff to be MSWindows-friendly (including many mappings). – Roflo Apr 21 '16 at 16:34
  • 7
    I use gvim daily on Windows, both the gvim GUI and the non-graphical vim via the cmder console. I too was frustrated until I turned off the mswin.vim config file and made a few other tweaks. I simply deleted the _vimrc file that was installed with the program and copied my Linux .vimrc over to Windows, then went from there. – Dan Jones Apr 21 '16 at 17:22
  • 6
    Other commenters have alluded to this, but no-one's actually said it outright: visual block works fine in Windows Vim. You just need to disable the "Windows friendly" key-bindings that override the ctrl-v key-combo with a paste mapping. It's possible (likely?) that your other issues with Windows Vim stem from the same problem, although you don't mention what they all are so it's hard to say for certain. – Rich Aug 17 '16 at 15:55
  • 4
    OOTB gvim on Windows works the same as on Linux (modulo different defaults for a few options). You must have it configured differently. – Antony Aug 24 '16 at 10:12
14

When I have to work on Windows (which is more often than I would like), I use Cygwin to get a terminal a little less crappy than the original Windows command line. Cygwin provides an environment which tries to be close to a Bash console with standard Linux commands, and of course it is far from being flawless.

See the project page of Cygwin. During the installation you'll end on a window allowing you to choose which packages you want to install. The search bar allows to look for packages to install, among other useful stuff (like git, tmux, curl, wget, etc.) you can type vim and select packages like vim, vim-common, vim-doc, gvim. This will install a Vim editor pretty close to what you're used to on Linux.

Once everything is installed (which can sometimes be a little long) you'll be able to start Cygwin which will show a terminal, and you'll be able to start Vim as usual and use your Linux .vimrc and your usual plugin manager. The main drawback is the compatibility of colors which often needs to be tweaked and still look crappy.

Note that I use Cygwin out of habit, but other solutions (like cmder for example) exist. None of them are flawless, so you might want to try several and find your favorite.

Also note that mintty is a good way to make Cygwin a little less crappy.

  • 1
    It has several issues. It doesn't show unicode characters properly. Some multi-byte characters are hidden. – SibiCoder May 22 '16 at 14:13
  • 1
    Yup that's precisely why i specified that "None of them are flawless": so far Cygwin (and equivalents) are just workaround. I'm not a Windows expert but maybe the new collaborative work between Canonical and Microsoft will lead to some better alternatives. – statox May 22 '16 at 14:34
  • I am using babun these days although I think the underlying cygwin is not as fresh as a vanilla install. – Rolf Sep 1 '17 at 7:40
  • Since Windows 10 and especially since the extra updates they've added to it (curl, openssh, correct text overflow, 24-bit colour support) that the straight DOS prompt is better now. The font rendering in the DOS / powershell prompts are typically the best that I've seen for Windows terminal apps. Plus if you install Git for Windows then that contains almost all the linux command line tools that you need, add C:\Program Files\Git\usr\bin or similar to your path. – icc97 Oct 12 '18 at 8:23
11

As of Windows 10 Anniversary Update, you can use the Bash on Ubuntu terminal to run a Linux subsystem where you can apt install anything you're used to inside Ubuntu. Your Windows file system is mounted so you can use Vim inside the shell to edit your files.

  • 2
    Bare in mind you're still accessing Vim through the Windows console, which is very limited with colours and syntax highlighting. Even with the creators update which is supposed to bring 256 colours to the console I haven't managed to improve the syntax highlighting. – icc97 Aug 31 '17 at 17:01
  • @icc97 I don't remember exactly what I did (I don't understand colors and terminals that well) but I was able to get colors that look fine on vim and fix the issue with the blue-on-black text that appeared in the bash on ubuntu terminal output. Now it's a bit colorful but it works fine. Also with Xming gVim works fine in Ubuntu on Windows (I just tested the interface and tried saving files etc.). – Formagella Sep 13 '17 at 13:25
  • @Formagella I'm a bit of a nitpicker with my colours. I spent hours trying to get solarized colours working to a similar standard of Linux Vim - I wrote up some of what I did in this issue. GVim however has pretty perfect syntax highlighting (and bold/italic) in Windows so I stopped struggling and just used that. Given that you're in the dos prompt just having OK syntax highlighting is great and it's very useful for SSH sessions, but for full time editing I gave up. – icc97 Sep 13 '17 at 13:36
  • 1
    There's now a version of Mintty available to act as the terminal for Bash on Ubuntu on Windows and an implementation of Solarized designed for Mintty. I did it just now and it was a relatively painless experience! – Amndeep7 Nov 15 '17 at 6:06
  • @Formagella I've finally got colours properly working in Windows console, it took a fix in Vim. But as of Vim 8.1 + a 24-bit colourscheme you can get lovely colours in the plain DOS prompt and WSL prompt. I have a separate answer that experiments with the various Windows console colorschemes and gets a couple working. – icc97 Oct 12 '18 at 8:28
4

As Roflo and Rich mentioned in their comment here and here, your problem with being unable to use visual block (I'm not sure what rx command is) is because the system-wide vimrc ($VIM\_vimrc) sources $VIMRUNTIME\mswin.vim which defines Windows-style mappings like Ctrl+v for paste, Ctrl+c for copy, Ctrl+x for cut.

The easiest way to get around this is to create a _vimrc files in your home directory (Note that Windows version of vim uses _vimrc instead of .vimrc). As you can see in :h vimrc, vim looks for vimrc in several locations and only uses the first one it finds while ignoring the rest. The one in the home directory is always searched/used first.

Minimal steps:

  • open gvim or vim
  • :e ~/_vimrc
  • :w
0

A further fairly small but no-less major update happened to Windows 10 for the 1803 build. They added 24-bit support for the console (cmd/powershell prompt). In Vim 8.1 (https://www.vim.org//download.php/#pc) they added support for termguicolors which means you can get the full 24-bit colour support inside the Vim console. I recently posted an answer of getting the colour support working.

But what it means is that there is pretty much full support for running Vim in the DOS prompt - so you don't need to install any Linux subsystem or any other dependencies beyond Vim itself to get pure Vim working. I find it still somewhat slow, but it's great to see the progress.

enter image description here

Things that work in Vim console (in Windows 10 build 1803+):

  • Airline with Powerline fonts
  • 24-bit colortheme (e.g. vim-solarized8, tender)
  • Pretty much any plugin (e.g. any Tim Pope plugin, FZF and Ripgrep)
  • vimdiff
  • The console Window snaps with correctly with the text flowing correctly - this is better handled than GVim

Things that don't work / problems:

  • It's slower than GVim
  • Bold / italic fonts
  • UTF-8 characters are a limited - e.g. some of the default Airline icons don't display

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.