当前位置:网站首页>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上进行下载。
本系列其他博客
边栏推荐
- 【网络安全】sql注入语法汇总
- Thread pool reject policy best practices
- Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
- 2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
- Regular expression integer positive integer some basic expressions
- mysql ”Invalid use of null value“ 解决方法
- Redis can only cache? Too out!
- Drawerlayout suppress sideslip display
- Excuse me, I have three partitions in Kafka, and the flinksql task has written the join operation. How can I give the join operation alone
- 搜索框效果的实现【每日一题】
猜你喜欢
566. 重塑矩阵
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
566. Reshaping the matrix
SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
docker部署oracle
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
Xshell connection server changes key login to password login
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
带你掌握三层架构(建议收藏)
随机推荐
Laravel5 call to undefined function openssl cipher iv length() 报错 PHP7开启OpenSSL扩展失败
Is the compass stock software reliable? Is it safe to trade stocks?
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
.net core 关于redis的pipeline以及事务
Cargo placement problem
Beginner XML
2022-7-6 Leetcode27.移除元素——太久没有做题了,为双指针如此狼狈的一天
高等数学---第八章多元函数微分学1
2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
Excuse me, why is it that there are no consumption messages in redis and they are all piled up in redis? Cerely is used.
Evolution of customer service hotline of dewu
2022-7-6 Leetcode 977. Square of ordered array
566. Reshaping the matrix
2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
postgresql array类型,每一项拼接
Excuse me, when using Flink SQL sink data to Kafka, the execution is successful, but there is no number in Kafka
Did login metamask
Excellent open source system recommendation of ThinkPHP framework
[daily training] 648 Word replacement