gVim configuration for Windows
Recently, because I was preparing for the GRE, I spent all day memorizing words, practicing listening, and writing. I felt quite annoyed and had not tinkered with anything for a long time. So I took some time to download and configure gVim on my laptop, which also counted as a break.
Download
Configuration Files
Unlike Linux, the gVim configuration files on Windows are $HOME/_vimrc for the personal configuration file and $VIMROOT/_vimrc for the system configuration file. By default, $VIMROOT is C:\Program Files (x86)\Vim. Besides these, there can also be a _gvimrc file, which is only read when opened in GUI mode, not in the terminal. This is helpful when applying different configurations to the two modes, especially when using different themes. The same theme can look very different in GUI and terminal mode. This avoids complicated configuration such as if(has'gui_running').
.vimrc Configuration
Open Configuration Files
:e $MYVIMRC: open the user configuration file. If it does not exist, refer tohelp vimrc.:e $MYGVIMRC: open the GUI user configuration.
The configuration file locations recommended in help vimrc are $HOME/vimfiles/vimrc on Windows or ~/.vim/vimrc on Unix-like systems. This is more portable than $HOME/_vimrc and ~/.vim.
Personalization
$MYGVIMRC
1 | set clipboard=unnamed " 与Windows公用clipboard, 默认情况下, y, p只使用vim的clipboard, 不是很方便 |
$MYVIMRC
1 | set number |
Markdown Support
Vim plugins can satisfy almost any need you have. However, here I do not use a Vim plugin; instead, I use a Chrome extension to satisfy my needs. The reason is that the configuration is simpler, and other editors can also use it in the future.
Plugin installation and usage instructions
Bind a shortcut. Add this to vimrc:
1 | " Open markdown files with Chrome. |
Press F5 when using it.
Afterword
This post was completed with gvim for MS-WINDOWS.