当前位置:网站首页>gvim【三】【_vimrc配置】
gvim【三】【_vimrc配置】
2022-07-07 12:11:00 【凳子花*】
GVIM可以通过修改vimrc来灵活配置你的编辑器。
这里先给出我的vimrc:
"设置背景主题
"colo Candy
set nocompatible
" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
" Remap a few keys for Windows behavior
source $VIMRUNTIME/mswin.vim
set expandtab
"set tabstop=4
set guifont=Courier_New:h14
"set guifont=DejaVu\ Sans\ Mono\:h14
"colorscheme eighties "主题设置
" Set window size
winpos 100 100
set lines=25 columns=80
" 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 =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
"自动全屏
"autocmd GUIEnter * simalt ~x
"设置编码"
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"显示行号"
set nu
set number
"突出显示当前行"
"set cursorline
"set cul "cursorline的缩写形式"
"突出显示当前列"
"set cursorcolumn
"set cuc "cursorcolumn的缩写形式"
"启用鼠标"
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"显示括号匹配"
set showmatch
"设置缩进"
"设置Tab长度为2空格"
set tabstop=2
"设置自动缩进长度为2空格"
set shiftwidth=2
"继承前一行的缩进方式,适用于多行注释"
set autoindent
"设置粘贴模式"
"显示空格和tab键在Vim中通过鼠标右键粘贴时会在行首多出许多缩进和空格,通过set paste可以在插入模式下粘贴内容时不会有任何格式变形、胡乱缩进等问题。"
set paste
"vimrc显示空格和tab键"
"Vim编辑器中默认不显示文件中的tab和空格符,通过下面的配置可以获得以下的显示效果,方便定位输入错误。"
set listchars=tab:>-,trail:-
"设置当文件被改动时自动载入
set autoread
"quickfix模式
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
"代码补全
set completeopt=preview,menu
"自动保存
set autowrite
"设置上下文行数
set so=1
" 语法高亮
set syntax=on
"与windows共享剪贴板
set clipboard+=unnamed
"取消自动备份及产生swp文件
set noundofile
set nobackup
set nowb
set noswapfile
"为C程序提供自动缩进
set smartindent
"启动的时候不显示那个援助索马里儿童的提示
set shortmess=atI
"忽略大小写
"set ic(ignorecase 的缩写) 忽略大小写
"set noic(noignorecase 的缩写) 不忽略大小写
"状态行显示的内容
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set statusline=\ [POS=%l,%v][%p%%]\ %{strftime(\"20%y/%m/%d\ -\ %H:%M\")}
"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu
"插件"
set nocompatible "去除VIM一致性,必须"
filetype off "必须"
"设置包括vundle和初始化相关的运行时路径"
set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
call vundle#begin('$VIM/vimfiles/bundle/')
"启用vundle管理插件,必须"
Plugin 'VundleVim/Vundle.vim'
"在此增加其他插件,安装的插件需要放在vundle#begin和vundle#end之间"
"安装github上的插件格式为 Plugin '用户名/插件仓库名'"
"括号颜色对齐
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'https://github.com/schmich/vim-guifont'
"目录
Plugin 'preservim/nerdtree'
Plugin 'preservim/nerdcommenter'
call vundle#end()
filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须"
autocmd VimEnter * RainbowParenthesesToggle
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"自动加载NERDTree
"autocmd VimEnter * NERDTree
" 设置NerdTree
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>
基本每种命令都添加了注释,大家结合注释来看就好,有些命令我不需要注释掉了,大家也可以取消注释看看是什么功能。
"插件"开始是添加了两个GVIM插件,GVIM插件的功能非常齐全,大家可以根据需要来安装不同的插件。我这里安装了两个:NERDTree和rainbow_parentheses。NERDTree是文件目录,rainbow_parentheses是括号颜色对齐。如下所示:

安装方法:
Gvim 树形目录插件 NERDTree 安装方法
vim插件——rainbow
vim插件: rainbow_parentheses[括号高亮]
博客中的文件从我的github上进行下载。
本系列其他博客
边栏推荐
- 118. 杨辉三角
- 118. Yanghui triangle
- 2022-7-6 Leetcode 977.有序数组的平方
- 室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
- IP and long integer interchange
- 566. Reshaping the matrix
- FCOS3D label assignment
- Is the spare money in your hand better to fry stocks or buy financial products?
- 2022-7-7 Leetcode 844.比较含退格的字符串
- 2022-7-6 Leetcode 977. Square of ordered array
猜你喜欢

LeetCode简单题分享(20)

手把手教会:XML建模

Deep understanding of array related problems in C language
![供应链供需预估-[时间序列]](/img/2c/82d118cfbcef4498998298dd3844b1.png)
供应链供需预估-[时间序列]

2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置

Evolution of customer service hotline of dewu

Transferring files between VMware and host

Use day JS let time (displayed as minutes, hours, days, months, and so on)

Hands on Teaching: XML modeling

Did login metamask
随机推荐
Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
Cesium knows the longitude and latitude of one point and the distance to find the longitude and latitude of another point
Laravel Form-builder使用
[daily training -- Tencent select 50] 231 Power of 2
Vmware共享主机的有线网络IP地址
Parsing of XML files
【AI实战】应用xgboost.XGBRegressor搭建空气质量预测模型(二)
【日常训练--腾讯精选50】231. 2 的幂
室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
请问指南针股票软件可靠吗?交易股票安全吗?
Environment configuration of lavarel env
Seven propagation behaviors of transactions
Help tenants
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
Cargo placement problem
Realize the IP address home display function and number home query
Leetcode simple question sharing (20)
为租客提供帮助
Mathématiques avancées - - chapitre 8 différenciation des fonctions multivariables 1
Is the spare money in your hand better to fry stocks or buy financial products?