当前位置:网站首页>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上进行下载。
本系列其他博客
边栏推荐
猜你喜欢
Leecode3. Longest substring without repeated characters
.net core 关于redis的pipeline以及事务
最长上升子序列模型 AcWing 482. 合唱队形
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
Details of redis core data structure & new features of redis 6
《厌女:日本的女性嫌恶》摘录
118. Yanghui triangle
AI talent cultivation new ideas, this live broadcast has what you care about
Take you to master the three-tier architecture (recommended Collection)
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
随机推荐
THINKPHP框架的优秀开源系统推荐
[daily training -- Tencent select 50] 231 Power of 2
Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
AI talent cultivation new ideas, this live broadcast has what you care about
js 获取当前时间 年月日,uniapp定位 小程序打开地图选择地点
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
How does MySQL control the number of replace?
Beginner XML
Is the compass stock software reliable? Is it safe to trade stocks?
. Net core about redis pipeline and transactions
mysql ”Invalid use of null value“ 解决方法
最长上升子序列模型 AcWing 1012. 友好城市
接口自动化测试-接口间数据依赖问题解决
When FC connects to the database, do you have to use a custom domain name to access it outside?
Oracle advanced (V) schema solution
内存溢出和内存泄漏的区别
TPG x AIDU | AI leading talent recruitment plan in progress!
648. 单词替换 : 字典树的经典运用
【日常训练--腾讯精选50】231. 2 的幂
Build a secure and trusted computing platform based on Kunpeng's native security