gvim(windows版 第二次改正)

2023-12-22 01:18
文章标签 windows 第二次 改正 gvim

本文主要是介绍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更改重命名的

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

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 版本号

 

好了,我们开始安装 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,没有扩展名,内容添加下面代码段:

 

"基本配置
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 onset 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.vimset diffexpr=MyDiff()
function MyDiff()let opt = '-a --binary 'if &diffopt =~ 'icase' | let opt = opt . '-i ' | endifif &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endiflet arg1 = v:fname_inif arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endiflet arg1 = substitute(arg1, '!', '\!', 'g')let arg2 = v:fname_newif arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endiflet arg2 = substitute(arg2, '!', '\!', 'g')let arg3 = v:fname_outif arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endiflet arg3 = substitute(arg3, '!', '\!', 'g')if $VIMRUNTIME =~ ' 'if &sh =~ '\<cmd'if empty(&shellxquote)let l:shxq_sav = ''set shellxquote&endiflet cmd = '"' . $VIMRUNTIME . '\diff"'elselet cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'endifelselet cmd = $VIMRUNTIME . '\diff'endiflet cmd = substitute(cmd, '!', '\!', 'g')silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3if exists('l:shxq_sav')let &shellxquote=l:shxq_savendif
endfunction

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

再次修改,_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 onset 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.vimset diffexpr=MyDiff()
function MyDiff()let opt = '-a --binary 'if &diffopt =~ 'icase' | let opt = opt . '-i ' | endifif &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endiflet arg1 = v:fname_inif arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endiflet arg1 = substitute(arg1, '!', '\!', 'g')let arg2 = v:fname_newif arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endiflet arg2 = substitute(arg2, '!', '\!', 'g')let arg3 = v:fname_outif arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endiflet arg3 = substitute(arg3, '!', '\!', 'g')if $VIMRUNTIME =~ ' 'if &sh =~ '\<cmd'if empty(&shellxquote)let l:shxq_sav = ''set shellxquote&endiflet cmd = '"' . $VIMRUNTIME . '\diff"'elselet cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'endifelselet cmd = $VIMRUNTIME . '\diff'endiflet cmd = substitute(cmd, '!', '\!', 'g')silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3if exists('l:shxq_sav')let &shellxquote=l:shxq_savendif
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 ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)if getline('.')[col('.') - 1] == a:charreturn "\<Right>"elsereturn a:charendif
endfunction

 运行python代码_vimrc配置

"运行python代码
autocmd BufRead *.py nmap <F5> :!python %<CR>

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

source $VIMRUNTIME/vimrc_example.vimset diffexpr=MyDiff()
function MyDiff()let opt = '-a --binary 'if &diffopt =~ 'icase' | let opt = opt . '-i ' | endifif &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endiflet arg1 = v:fname_inif arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endiflet arg1 = substitute(arg1, '!', '\!', 'g')let arg2 = v:fname_newif arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endiflet arg2 = substitute(arg2, '!', '\!', 'g')let arg3 = v:fname_outif arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endiflet arg3 = substitute(arg3, '!', '\!', 'g')if $VIMRUNTIME =~ ' 'if &sh =~ '\<cmd'if empty(&shellxquote)let l:shxq_sav = ''set shellxquote&endiflet cmd = '"' . $VIMRUNTIME . '\diff"'elselet cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'endifelselet cmd = $VIMRUNTIME . '\diff'endiflet cmd = substitute(cmd, '!', '\!', 'g')silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3if exists('l:shxq_sav')let &shellxquote=l:shxq_savendif
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 onset 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 onset 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.vimset diffexpr=MyDiff()
function MyDiff()let opt = '-a --binary 'if &diffopt =~ 'icase' | let opt = opt . '-i ' | endifif &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endiflet arg1 = v:fname_inif arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endiflet arg1 = substitute(arg1, '!', '\!', 'g')let arg2 = v:fname_newif arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endiflet arg2 = substitute(arg2, '!', '\!', 'g')let arg3 = v:fname_outif arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endiflet arg3 = substitute(arg3, '!', '\!', 'g')if $VIMRUNTIME =~ ' 'if &sh =~ '\<cmd'if empty(&shellxquote)let l:shxq_sav = ''set shellxquote&endiflet cmd = '"' . $VIMRUNTIME . '\diff"'elselet cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'endifelselet cmd = $VIMRUNTIME . '\diff'endiflet cmd = substitute(cmd, '!', '\!', 'g')silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3if exists('l:shxq_sav')let &shellxquote=l:shxq_savendif
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 <F12>:!python.exe %
"nnoremap <silent> <F2> :NERDTree<CR>
"运行python代码
autocmd BufRead *.py nmap <F5> :!python %<CR>"python代码补全(neocomplcache)---> 成功补全 ---按tab键可以跟踪内部代码,这个是原先带的补全代码。
set completeopt-=preview
let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
"自动补全括号:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)if getline('.')[col('.') - 1] == a:charreturn "\<Right>"elsereturn a:charendif
endfunction
" 关闭NERDTree快捷键
map <F2> :NERDTreeMirror<CR> 
map <F2> :NERDTreeToggle<CR>
map <leader>t :NERDTreeToggle<CR>
" 显示行号
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 <bruce.oy@gmail.com>
"
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 <silent> <F3> :TlistToggle<CR>    "打开tag窗口,这个是设置快捷键""""""""""""""
"winmanager > 用法:normal模式下按快捷键w+m,同时按下去就可以。
""""""""""""""
let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'
"nmap <silent> <F10> :WMToggle<cr>
nmap wm :WMToggle<cr> " 是nomal模式的命令,不是Ex模式的,这个是设置快捷键

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

参考博客(链接):

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

这篇关于gvim(windows版 第二次改正)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/522145

相关文章

Windows设置nginx启动端口的方法

《Windows设置nginx启动端口的方法》在服务器配置与开发过程中,nginx作为一款高效的HTTP和反向代理服务器,被广泛应用,而在Windows系统中,合理设置nginx的启动端口,是确保其正... 目录一、为什么要设置 nginx 启动端口二、设置步骤三、常见问题及解决一、为什么要设置 nginx

在 Windows 上安装 DeepSeek 的完整指南(最新推荐)

《在Windows上安装DeepSeek的完整指南(最新推荐)》在Windows上安装DeepSeek的完整指南,包括下载和安装Ollama、下载DeepSeekRXNUMX模型、运行Deep... 目录在www.chinasem.cn Windows 上安装 DeepSeek 的完整指南步骤 1:下载并安装

windows系统下shutdown重启关机命令超详细教程

《windows系统下shutdown重启关机命令超详细教程》shutdown命令是一个强大的工具,允许你通过命令行快速完成关机、重启或注销操作,本文将为你详细解析shutdown命令的使用方法,并提... 目录一、shutdown 命令简介二、shutdown 命令的基本用法三、远程关机与重启四、实际应用

Windows自动化Python pyautogui RPA操作实现

《Windows自动化PythonpyautoguiRPA操作实现》本文详细介绍了使用Python的pyautogui库进行Windows自动化操作的实现方法,文中通过示例代码介绍的非常详细,对大... 目录依赖包睡眠:鼠标事件:杀死进程:获取所有窗口的名称:显示窗口:根据图片找元素:输入文字:打开应用:依

javafx 如何将项目打包为 Windows 的可执行文件exe

《javafx如何将项目打包为Windows的可执行文件exe》文章介绍了三种将JavaFX项目打包为.exe文件的方法:方法1使用jpackage(适用于JDK14及以上版本),方法2使用La... 目录方法 1:使用 jpackage(适用于 JDK 14 及更高版本)方法 2:使用 Launch4j(

windows端python版本管理工具pyenv-win安装使用

《windows端python版本管理工具pyenv-win安装使用》:本文主要介绍如何通过git方式下载和配置pyenv-win,包括下载、克隆仓库、配置环境变量等步骤,同时还详细介绍了如何使用... 目录pyenv-win 下载配置环境变量使用 pyenv-win 管理 python 版本一、安装 和

Python使用pysmb库访问Windows共享文件夹的详细教程

《Python使用pysmb库访问Windows共享文件夹的详细教程》本教程旨在帮助您使用pysmb库,通过SMB(ServerMessageBlock)协议,轻松连接到Windows共享文件夹,并列... 目录前置条件步骤一:导入必要的模块步骤二:配置连接参数步骤三:实例化SMB连接对象并尝试连接步骤四:

在 Windows 上部署 gitblit

在 Windows 上部署 gitblit 在 Windows 上部署 gitblit 缘起gitblit 是什么安装JDK部署 gitblit 下载 gitblit 并解压配置登录注册为 windows 服务 修改 installService.cmd 文件运行 installService.cmd运行 gitblitw.exe查看 services.msc 缘起

Windows如何添加右键新建菜单

Windows如何添加右键新建菜单 文章目录 Windows如何添加右键新建菜单实验环境缘起以新建`.md`文件为例第一步第二步第三步 总结 实验环境 Windows7 缘起 因为我习惯用 Markdown 格式写文本,每次新建一个.txt后都要手动修改为.md,真的麻烦。如何在右键新建菜单中添加.md选项呢? 网上有很多方法,这些方法我都尝试了,要么太麻烦,要么不凑效

Windows下Nginx的安装及开机启动

1、将nginx-1.16.1.zip解压拷贝至D:\web\nginx目录下。 2、启动Nginx,两种方法: (1)直接双击nginx.exe,双击后一个黑色的弹窗一闪而过。 (2)打开cmd命令窗口,切换到nginx目录下,输入命令 nginx.exe 或者 start nginx ,回车即可。 3、检查nginx是否启动成功。 直接在浏览器地址栏输入网址 http://lo