Linux系统 | vim配置
fly@fly-vm:~$ cat /etc/vim/vimrc
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below. If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"VIM打开文件光标自动跳转至文件上一次打开的地方
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
filetype plugin indent on
endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"=====================================================================================
set mouse=a "使用鼠标,可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set selection=exclusive
set selectmode=mouse,key
set laststatus=2 "显示状态行
set cmdheight=1 "命令行(在状态行下)的高度
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
"状态行显示的内容
set statusline=%F%m%r%h%w\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容
set cindent "C代码自动缩进
filetype indent on "自适应不同语言的职能缩进
set expandtab "将制表符扩展为空格
set tabstop=4 "设置编辑时制表符占用空格数
set softtabstop=4 "让vim把连续数量的空格视为一个制表符
set shiftwidth=4 "设置格式化时制表符占用的空格数
set smarttab "智能Tab
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 "编码设置
set termencoding=utf-8
set encoding=utf-8
set scrolloff=2 "光标移动到Buffer顶部和底部保持5行间距
set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set matchtime=1 "匹配括号高亮的时间(单位是十分之一秒)
set number "显示行号
set cursorline "高亮显示当前行
"set cursorcolumn "高亮显示当前列
set ruler "开启行号显示
set hlsearch "高亮显示搜索结果
set guifont=YaHei\ Consolas\ Hybrid\ 12 "设置gvim显示字体
let g:Powerline_colorscheme='solarized256' "设置状态栏主题风格
syntax enable "开启语法高亮功能
syntax on "允许用指定语法高亮配色方案替换默认方案
"=====================================================================================
"===================================新文件标题========================================
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewfile *.sh,*.cpp,*.c,*.java exec ":call SetTitle()"
"定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1,"\###################################################################")
call append(line(".")+0,"\ # File Name: ".expand("%"))
call append(line(".")+1,"\ # Author: fly")
call append(line(".")+2,"\ # Mail: 1358326274@qq.com")
call append(line(".")+3,"\ # Created Time: ".strftime("%c"))
call append(line(".")+4,"\###################################################################")
call append(line(".")+5,"\#!/bin/bash")
call append(line(".")+6,"")
else
call setline(1,"/*******************************************************************")
call append(line(".")+0," * > File Name: ".expand("%"))
call append(line(".")+1," * > Author: fly")
call append(line(".")+2," * > Mail: 1358326274@qq.com")
call append(line(".")+3," * > Create Time: ".strftime("%c"))
call append(line(".")+4," ******************************************************************/")
call append(line(".")+5,"")
endif
if &filetype == 'java'
call setline(1,"/*")
call setline(6," */")
endif
if &filetype == 'cpp'
call append(line(".")+6,"#include <iostream>")
call append(line(".")+7,"using namespace std;")
call append(line(".")+8,"")
call append(line(".")+9,"int main(void)")
call append(line(".")+10,"{")
call append(line(".")+11," return 0;")
call append(line(".")+12,"}")
endif
if &filetype == 'c'
call append(line(".")+6,"#include <stdio.h>")
call append(line(".")+7,"")
call append(line(".")+8,"int main(int argc, char* argv[])")
call append(line(".")+9,"{")
call append(line(".")+10," return 0;")
call append(line(".")+11,"}")
endif
endfunc
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
|