当前位置:网站首页>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上进行下载。
本系列其他博客
边栏推荐
- [daily training -- Tencent select 50] 231 Power of 2
- Leetcode simple question sharing (20)
- Custom thread pool rejection policy
- 2022-7-6 Leetcode 977. Square of ordered array
- FCOS3D label assignment
- Environment configuration of lavarel env
- 【面试高频题】难度 2.5/5,简单结合 DFS 的 Trie 模板级运用题
- Is it safe to open an account online now? Which securities company should I choose to open an account online?
- 648. 单词替换 : 字典树的经典运用
- THINKPHP框架的优秀开源系统推荐
猜你喜欢
室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
为租客提供帮助
AI人才培育新思路,这场直播有你关心的
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
XML文件的解析操作
Realize the IP address home display function and number home query
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
作战图鉴:12大场景详述容器安全建设要求
【堡垒机】云堡垒机和普通堡垒机的区别是什么?
Custom thread pool rejection policy
随机推荐
648. 单词替换 : 字典树的经典运用
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
Beginner XML
Xshell connection server changes key login to password login
"New red flag Cup" desktop application creativity competition 2022
Help tenants
Excusez - moi, l'exécution a été réussie lors de l'utilisation des données de puits SQL Flink à Kafka, mais il n'y a pas de nombre dans Kafka
call undefined function openssl_ cipher_ iv_ length
请问,redis没有消费消息,都在redis里堆着是怎么回事?用的是cerely 。
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
ES日志报错赏析-Limit of total fields
Use day JS let time (displayed as minutes, hours, days, months, and so on)
高等数学---第八章多元函数微分学1
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (II)
Attribute keywords aliases, calculated, cardinality, ClientName
Leecode3. Longest substring without repeated characters
FCOS3D label assignment
Dry goods | summarize the linkage use of those vulnerability tools
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
【日常训练--腾讯精选50】231. 2 的幂