当前位置:网站首页>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上进行下载。
本系列其他博客
边栏推荐
- The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
- Excerpt from "misogyny: female disgust in Japan"
- 566. Reshaping the matrix
- 云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
- Realization of search box effect [daily question]
- Navicat run SQL file import data incomplete or import failed
- Help tenants
- Is the compass stock software reliable? Is it safe to trade stocks?
- 648. Word replacement: the classic application of dictionary tree
- Flask session forged hctf admin
猜你喜欢
AI人才培育新思路,这场直播有你关心的
.net core 关于redis的pipeline以及事务
Xshell connection server changes key login to password login
2022-7-6 Leetcode 977. Square of ordered array
TPG x AIDU | AI leading talent recruitment plan in progress!
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
Selenium库
docker部署oracle
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
作战图鉴:12大场景详述容器安全建设要求
随机推荐
call undefined function openssl_cipher_iv_length
Beginner XML
Excuse me, when using Flink SQL sink data to Kafka, the execution is successful, but there is no number in Kafka
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
Redis只能做缓存?太out了!
The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
干货|总结那些漏洞工具的联动使用
Environment configuration of lavarel env
Build a secure and trusted computing platform based on Kunpeng's native security
FCOS3D label assignment
requires php ~7.1 -&gt; your PHP version (7.0.18) does not satisfy that requirement
请问,在使用flink sql sink数据到kafka的时候出现执行成功,但是kafka里面没有数
搜索框效果的实现【每日一题】
AI talent cultivation new ideas, this live broadcast has what you care about
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
Drawerlayout suppress sideslip display
648. Word replacement: the classic application of dictionary tree
2022-7-6 Leetcode27.移除元素——太久没有做题了,为双指针如此狼狈的一天
Is the compass stock software reliable? Is it safe to trade stocks?