gvim(windows版 第二次改正)

本项中使用的所有插件:gvim,git,curl,vundle,NERDTree ,vim-nerdtree-tabs,CtrlP,neocomplcache,ctags,taglist,winmanager

gvim下载:

官方下载地址:http://www.vim.org/download.php

百度网盘:

链接:https://pan.baidu.com/s/1MR_exH0ASy-j5GEB2X0g5Q 
提取码:6e93

1. 安装gvim 

下载 》 安装 》加入环境变量path(只要点击安装程序exe即可,按下一步就可以了,安装步骤简单,不多说,不知道百度一下一大堆。)

我的gvim安装位置: D:\gvim\Vim  (这个路径下也可以放_vimrc,与家目录是同样的效果。下面的_vimrc_s把原来_vimrc更改重命名的

gvim(windows版 第二次改正)_第1张图片

 家目录截图展示:(红圈标记.vim和_vimrc)

gvim(windows版 第二次改正)_第2张图片

2. 安装插件管理工具vundle

注意:安装vundle前提需要先安装 git 和 配置curl

git 》 下载运行程序exe 》 然后双击exe,一直下一步,简单。安装参考地址:https://www.cnblogs.com/tuhooo/p/7497233.html

配置curl:

在windows下安装curl与msysgit结合非常简单,只需要在git的cmd目录创建文件curl.cmd即可
路径:D:\Git\cmd\curl.cmd ,文件内容如下

@rem Do not use "echo off" to not affect any child calls.
@setlocal
 
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\mingw64\bin;%PATH%
@rem !!!!!!! For 64bit msysgit, replace 'mingw' above with 'mingw64' !!!!!!!
 
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
 
@curl.exe %*

打开cmd 命令提示符,运行命令( curl --version )检查curl 版本号

gvim(windows版 第二次改正)_第3张图片

 

好了,我们开始安装 vundle 了,也很简单

安装Vundle   (Vundle on Windows) git clone(简单理解就是从网上复制内容到本地)

win + r,打开cmd运行:git clone https://github.com/gmarik/Vundle.vim.git $HOME\.vim\bundle\Vundle.vim

C:\Users\nala(用户名),这个目录下生成$HOME目录,把里面的.vim文件夹复制到C:\Users\nala目录,然后从家目录中就可以加载vundle插件了(提前提醒一下,_vimrc中rtp是 set rtp+=.vim\bundle\Vundle.vim\ 然后_vimrc就从家目录中找到vundle插件了),到这里下面红色圈中显示的文件夹(.vim)和文件(_vimrc)存在就可以了,如果没有_vimrc,使用记事本创建_vimrc,没有扩展名,内容添加下面代码段:

gvim(windows版 第二次改正)_第4张图片

 

"基本配置
set nobackup
set noundofile
set noswapfile
set helplang=cn
set encoding=utf-8
"set fileencoding=utf-8
syntax enable
syntax on
colorscheme desert
set number
set cursorline
set ruler
set autoindent
"filetype on
"filetype plugin on
"filetype indent on
 
 
set nocompatible              " be iMproved, required,不去兼容vi
filetype off                  " required, "关闭文件类型检测


"插件管理
"set rtp+=D:\gvim\Vim\vimfiles\bundle\Vundle.vim\   "加个绝对路径就可以,gvim运行加载_vimrc时能找到上面路径即可。
set rtp+=.vim\bundle\Vundle.vim\
call vundle#begin()
"let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"my bundle plugin
"Plugin 'Shougo/neocomplcache.vim'
"Plugin 'scrooloose/nerdtree'
"Plugin 'jistr/vim-nerdtree-tabs'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
"Plugin 'kien/ctrlp.vim'
"Plugin 'eshion/vim-sync'
call vundle#end()
filetype plugin indent on

"vim81自带配置
source $VIMRUNTIME/vimrc_example.vim

set diffexpr=MyDiff()
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

然后打开vim,normal模式下执行:BundleInstall,展示下图:

gvim(windows版 第二次改正)_第5张图片

再次修改,_vimrc ,就是前面的几个插件的注释去掉,然后安装插件,就是执行BundleInstall,就自动安装插件了。

"基本配置
set nobackup
set noundofile
set noswapfile
set helplang=cn
set encoding=utf-8
"set fileencoding=utf-8
syntax enable
syntax on
colorscheme desert
set number
set cursorline
set ruler
set autoindent
"filetype on
"filetype plugin on
"filetype indent on
 
 
set nocompatible              " be iMproved, required,不去兼容vi
filetype off                  " required, "关闭文件类型检测


"插件管理
"set rtp+=D:\gvim\Vim\vimfiles\bundle\Vundle.vim\   "加个绝对路径就可以,gvim运行加载_vimrc时能找到上面路径即可。
set rtp+=.vim\bundle\Vundle.vim\
call vundle#begin()
"let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"my bundle plugin
"Plugin 'Shougo/neocomplcache.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'kien/ctrlp.vim'
Plugin 'eshion/vim-sync'
call vundle#end()
filetype plugin indent on

"vim81自带配置
source $VIMRUNTIME/vimrc_example.vim

set diffexpr=MyDiff()
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

ctags的安装

这个安装非常简单,在http://ctags.sourceforge.net/下载windows的版本ctags58.zip,
然后解压出来,在Path里添加.exe所在的路径即可

安装完成后用":ctags -R"可以在目录下生成tags文件,记录索引
Ctrl+]可以实现跳转

taglist的安装

下载安装包:http://www.vim.org/scripts/script.php?script_id=273

解压出来有两个文件夹,其内个有一个文件:\doc\taglist.txt和\plugin\taglist.vim

将两个文件分别拷贝到D:\gvim\Vim\vim81下面的doc和plugin文件夹中

用管理员身份打开gvim 运行":helptags D:\gvim\Vim\vim81\doc "

winmanager插件的安装

下载地址:winmanager.zip 地址http://www.vim.org/scripts/download_script.php?src_id=754

winmanager安装很简单,与上面taglist安装方式一样。

"自动补全各种括号引号_vimrc中的配置

"自动补全括号
 
:inoremap ( ()i
:inoremap ) =ClosePair(')')
:inoremap { {}O
:inoremap } =ClosePair('}')
:inoremap [ []i
:inoremap ] =ClosePair(']')
:inoremap " ""i
:inoremap ' ''i
function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
		        return "\"
	else
			    return a:char
	endif
endfunction

 运行python代码_vimrc配置

"运行python代码
autocmd BufRead *.py nmap  :!python %

原来就在_vimrc中的配置(就是没有理由,就是必须要这个配置,原样不动的复制黏贴就ok)

source $VIMRUNTIME/vimrc_example.vim
 
set diffexpr=MyDiff()
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

vundle配置

"插件管理
set rtp+=D:\gvim\Vim\vimfiles\bundle\Vundle.vim  "就直接用绝对路径vim配置项
"set rtp+=$VIM\vimfiles\bundle\Vundle.vim\
call vundle#begin()
"let Vundle manage Vundle, required
" =======================================================
" 安装插件写在这之后
" =======================================================
 
 
Plugin 'VundleVim/Vundle.vim'
"my bundle plugin
Plugin 'Shougo/neocomplcache.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'kien/ctrlp.vim'
Plugin 'eshion/vim-sync'
 
 
" =======================================================
" 安装插件写在这之前
" =======================================================
"相关命令
 
"安装插件:BundleInstall
"更新插件:BundleUpdate
"清除不再使用的插件:BundleClean
"列出所有插件:BundleList
"查找插件:BundleSearch
call vundle#end()
filetype plugin indent on

基本vim必须配置

set nobackup
set noundofile
set noswapfile
set helplang=cn
set encoding=utf-8
"set fileencoding=utf-8
syntax enable
syntax on
colorscheme desert
set number
set cursorline
set ruler
set autoindent
"filetype on
"filetype plugin on
"filetype indent on
 
 
set nocompatible              " be iMproved, required,不去兼容vi
filetype off                  " required, "关闭文件类型检测

最后,附上我的_vimrc 完整配置

"基本配置
set nobackup
set noundofile
set noswapfile
set helplang=cn
set encoding=utf-8
"set fileencoding=utf-8
syntax enable
syntax on
colorscheme desert
set number
set cursorline
set ruler
set autoindent
"filetype on
"filetype plugin on
"filetype indent on
 
 
set nocompatible              " be iMproved, required,不去兼容vi
filetype off                  " required, "关闭文件类型检测


"插件管理
"set rtp+=D:\gvim\Vim\vimfiles\bundle\Vundle.vim\   "加个绝对路径就可以,gvim运行加载_vimrc时能找到上面路径即可。
set rtp+=.vim\bundle\Vundle.vim\
call vundle#begin()
"let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"my bundle plugin
Plugin 'Shougo/neocomplcache.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'kien/ctrlp.vim'
Plugin 'eshion/vim-sync'
call vundle#end()
filetype plugin indent on

"vim81自带配置
source $VIMRUNTIME/vimrc_example.vim

set diffexpr=MyDiff()
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


"let Tlist_Ctags_Cmd='ctags.exe'
"打开侧边栏
"let Tlist_Auto_Open=1
"let g:pydiction_location ='D:\gvim\Vim\vim81\ftplugin\complete-dict'
"let g:pydiction_menu_height = 20
"map :!python.exe %
"nnoremap   :NERDTree
"运行python代码
autocmd BufRead *.py nmap  :!python %
 
 
 
 
"python代码补全(neocomplcache)---> 成功补全 ---按tab键可以跟踪内部代码,这个是原先带的补全代码。
set completeopt-=preview
let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
"自动补全括号
 
:inoremap ( ()i
:inoremap ) =ClosePair(')')
:inoremap { {}O
:inoremap } =ClosePair('}')
:inoremap [ []i
:inoremap ] =ClosePair(']')
:inoremap " ""i
:inoremap ' ''i
function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
		        return "\"
	else
			    return a:char
	endif
endfunction
" 关闭NERDTree快捷键
map  :NERDTreeMirror 
map  :NERDTreeToggle
map t :NERDTreeToggle
" 显示行号
let NERDTreeShowLineNumbers=1
let NERDTreeAutoCenter=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=21
" 在终端启动vim时,共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['\.pyc','\~$','\.swp']
" 显示书签列表
let NERDTreeShowBookmarks=1
 
 
"ctags 用法
"项目文件夹的终端命令行中运行:ctags -R,然后执行查找命令ctrl + ],自动跳转到源码。
 
"taglist的用法
"gvim命令模式中执行:Tlist,就会显示taglist窗口。 fn + f3也显示taglist窗口。
 
 
"Taglist------------------------------------------------
"==================================================
let Tlist_Show_Menu=1
"let Tlist_Ctags_Cmd='D:\ctags58\ctags.exe'”这句话可有可无,但我还是加了,以防万一
let Tlist_Auto_Open=1
let Tlist_File_Fold_Auto_Close=0
let Tlist_Compact_Format=1
let Tlist_Enable_Fold_Column=1
let Tlist_Sort_Type="order"
set tags=tags;
set autochdir         " 自动设置目录为正在编辑的文件所在的目录
 
"filetype plugin on
" taglist configuration vimrc file.
"
" Maintainer:     Bruce Ouyang 
"
let Tlist_Display_Prototype = 1
let Tlist_Sort_Type = "order"           "使taglist以tag名字进行排序
let Tlist_Show_One_File = 1            "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 0         "在右侧窗口中显示taglist窗口
let Tlist_Use_SingleClick = 1          "单击tag就跳转到定义
let Tlist_GainFocus_On_ToggleOpen = 1  "使用:TlistToggle打开taglist窗口时,输入焦点在taglist窗口中
nmap   :TlistToggle    "打开tag窗口,这个是设置快捷键
 
 
""""""""""""""
"winmanager > 用法:normal模式下按快捷键w+m,同时按下去就可以。
""""""""""""""
let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'
"nmap   :WMToggle
nmap wm :WMToggle " 是nomal模式的命令,不是Ex模式的,这个是设置快捷键

到此结束,愉快的使用vim了。

参考博客(链接):

https://blog.csdn.net/sinat_28617733/article/details/102149185

你可能感兴趣的:(编辑器,gvim配置)