加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim 配置

发布时间:2020-12-15 17:05:16 所属栏目:安全 来源:网络整理
导读:cp /usr/share/vim/vimrc /usr/share/vim/vimrc_backup " Configuration file for vimset modelines=0" CVE-2007-2438" Normally we use vim-extensions. If you want true vi-compatibility" remove change the following statementsset nocompatible" Use

cp /usr/share/vim/vimrc/usr/share/vim/vimrc_backup



" Configuration file for vim
set modelines=0		" CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible	" Use Vim defaults instead of 100% vi compatibility
set backspace=2		" more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup nobackup


" 以下内容为新增内容

set showmatch         " 高亮显示对应的括号

set number            " 显示行号

set cindent           " C风格的对齐方式

set autoindent        " 自动对齐

set confirm           " 在处理未保存或只读文件的时候,弹出确认

set tabstop=4         " Tab键的宽度

syntax on             " 自动语法高亮

set softtabstop=4

set shiftwidth=4      " 统一缩进为4

set mouse=a           " 开启鼠标功能
set selection=exclusive
set selectmode=mouse,key

set guifont=Courier_New:h10:cANSI   " 设置字体 

" 编码设置
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

" 语言设置
set langmenu=zh_CN.UTF-8
set helplang=cn

" 我的状态行显示的内容(包括文件类型和解码)
set statusline=%F%m%r%h%w [FORMAT=%{&ff}] [TYPE=%Y] [POS=%l,%v][%p%%] %{strftime("%d/%m/%y - %H:%M")}
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]

" 总是显示状态行
set laststatus=2

" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=2

set hlsearch
set incsearch         " 搜索逐字符高亮

set gdefault          " 行内替换

set matchtime=5       " 对应括号高亮的时间(单位是十分之一秒)

" 设置当文件被改动时自动载入
set autoread

" 共享剪贴板
set clipboard+=unnamed

" 映射全选+复制 ctrl+a
map <C-A> ggVGY
map! <C-A> <Esc>ggVGY
map <F12> gg=G

"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "&;Right>"
	 else
		 return a:char
	 endif
endfunction
filetype plugin indent on 
"打开文件类型检测,加了这句才可以用智能补全
set completeopt=longest,menu


References: http://blog.csdn.net/freeking101/article/details/62037015


@qingdujun

2017-11-18 北京 怀柔

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读