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

相关文章

在C#中调用Windows防火墙界面的常见方式

《在C#中调用Windows防火墙界面的常见方式》在C#中调用Windows防火墙界面(基础设置或高级安全设置),可以使用进程启动(Process.Start)或Win32API来实现,所以本文给大家... 目录引言1. 直接启动防火墙界面(1) 打开基本防火墙设置(firewall.cpl)(2) 打开高

基于Python实现局域网内Windows桌面文件传输

《基于Python实现局域网内Windows桌面文件传输》这篇文章介绍了如何使用Python实现一个局域网文件传输系统,包括发送端和接收端的代码示例,发送端和接收端都需要在同一局域网内运行,并且确保防... 目录发送端代码 (sender.py)接收端代码 (receiver.py)图形界面版本 (可选)使

Linux挂载linux/Windows共享目录实现方式

《Linux挂载linux/Windows共享目录实现方式》:本文主要介绍Linux挂载linux/Windows共享目录实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录文件共享协议linux环境作为服务端(NFS)在服务器端安装 NFS创建要共享的目录修改 NFS 配

基于Python开发Windows自动更新控制工具

《基于Python开发Windows自动更新控制工具》在当今数字化时代,操作系统更新已成为计算机维护的重要组成部分,本文介绍一款基于Python和PyQt5的Windows自动更新控制工具,有需要的可... 目录设计原理与技术实现系统架构概述数学建模工具界面完整代码实现技术深度分析多层级控制理论服务层控制注

Oracle数据库在windows系统上重启步骤

《Oracle数据库在windows系统上重启步骤》有时候在服务中重启了oracle之后,数据库并不能正常访问,下面:本文主要介绍Oracle数据库在windows系统上重启的相关资料,文中通过代... oracle数据库在Windows上重启的方法我这里是使用oracle自带的sqlplus工具实现的方

Windows环境下解决Matplotlib中文字体显示问题的详细教程

《Windows环境下解决Matplotlib中文字体显示问题的详细教程》本文详细介绍了在Windows下解决Matplotlib中文显示问题的方法,包括安装字体、更新缓存、配置文件设置及编码調整,并... 目录引言问题分析解决方案详解1. 检查系统已安装字体2. 手动添加中文字体(以SimHei为例)步骤

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4

Windows下C++使用SQLitede的操作过程

《Windows下C++使用SQLitede的操作过程》本文介绍了Windows下C++使用SQLite的安装配置、CppSQLite库封装优势、核心功能(如数据库连接、事务管理)、跨平台支持及性能优... 目录Windows下C++使用SQLite1、安装2、代码示例CppSQLite:C++轻松操作SQ

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1