windows10安装配置vim8.2

windows10 安装配置vim8.2

安装64位vim

当python安装的是64位,那么一定要下载和安装64位的vim,因为有些插件会用到python的dll,否者,可能会出现问题。现在大家的电脑应该都是64位了,建议大家统一64位。

64位vim windows下载路径https://github.com/vim/vim-win32-installer/releases
选择gvim_8.2***_x64.exe

64位python3.8

安装vim,假设安装在D:\Software\Vim\

下载vim-plug这个插件

https://github.com/junegunn/vim-plug/blob/master/plug.vim保存到~\vimfiles\autoload\这个目录下,如果没有就先创建

修改vim配置文件,windows下是~\_vimrc

" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
source ~\vimfiles\autoload\plug.vim

" 之后通过vim-plug安装的插件就会安装到`~\vimfiles\plugged`这个目录下
" vim-plug的README上说,要避免使用`plugin`这个目录的名称,防止和vim标准的插件混淆
call plug#begin('~\vimfiles\plugged') 
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }

" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" markdown-preview
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install'  }

call plug#end()

" 设置配色方案
colorscheme morning
" 字体类型和大小
set guifont=Consolas:h12
set nu
set relativenumber

" 换行时,自动缩进4列; 使用`<`或者`>`缩进时,缩进4列
set shiftwidth=4 

set tabstop=4

" 把输入的tab字符替换空格,具体空格数,跟tabstop设置的值有关
expandtab

" 会影响到Backspace键删除多个空格和删除tab字符的行为
set softtabstop=4

set fileencodings=utf-8,chinese,latin-1
set encoding=utf-8
set belloff=all
syntax on
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
" 解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
  if &sh =~ '\ ' . arg3
if exists('l:shxq_sav')
  let &shellxquote=l:shxq_sav
endif
endfunction

然后执行:PlugInstall 安装这些插件,过程有点慢,如果等不了,可以先把插件download下来,
直接放在~\vimfiles\plugged\这个目录下

后期再记录一些vim有用的一些技巧和插件

技巧1

vim new_dir/new_file.md
当保存文件时,提示E212: Can't open file for writing

解决方法:

  • windows下
    :!MD -p %:h
  • linux下
    :!mkdir -p %:h

你可能感兴趣的:(windows10,vim)