diff --git a/profile/vimrc b/profile/vimrc new file mode 100644 index 0000000..37b0eca --- /dev/null +++ b/profile/vimrc @@ -0,0 +1,174 @@ +" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just +" /usr/share/vim/vimcurrent/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 +" following 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 +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 + +"-------------------------------------- +"Personality Setting +"-------------------------------------- +syntax on +"set number +set ruler +set laststatus=2 " always show the status line +set history=2048 +set lbr +" 设置当文件被改动时自动载入 +set autoread +" 不要备份文件(根据自己需要取舍) +set nobackup +" 不要生成swap文件,当buffer被丢弃的时候隐藏它 +setlocal noswapfile +set bufhidden=hide +" 在状态行上显示光标所在位置的行号和列号 +set ruler +set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%) +" 命令行(在状态行下)的高度,默认为1,这里是2 +set cmdheight=1 +" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位) +set mouse= +set selection=exclusive +set selectmode=mouse,key +" 启动的时候不显示那个援助索马里儿童的提示 +"set shortmess=atI +" 通过使用: commands命令,告诉我们文件的哪一行被改变过 +set report=0 + +"------------------------------------------------------------------------------------- +" text formatting/layout +"------------------------------------------------------------------------------------- +"set ai " autoindent +"set si " smartindent +"set cindent " do C-style indenting +set fo=tcrqn " see help (complex) +"set tabstop=1 " tab spacing (settings below are just to unify it) +"set softtabstop=4 " unify +"set shiftwidth=1 " unify +"set noexpandtab " real tabs please! +"set smarttab " use tabs at the start of a line, spaces elsewhere +"set nowrap " do not wrap lines +set formatoptions+=mM " so that vim can reformat multibyte text (e.g. Chinese) +autocmd FileType python setlocal et sta sw=2 sts=2 +autocmd FileType javascript setlocal et sta sw=2 sts=2 +autocmd FileType html setlocal et sta sw=2 sts=2 +autocmd FileType c setlocal et sta sw=4 sts=4 + +"------------------------------------------------------------------------------------- +" gui-only settings +"------------------------------------------------------------------------------------- +if has("gui_running") +colo desert " colorscheme, desert.vim +set lines=60 " window tall and wide, only if gui_running, +set columns=110 " or vim under console behaves badly +endif + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" 搜索和匹配 +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" 高亮显示匹配的括号 +set showmatch +" 匹配括号高亮的时间(单位是十分之一秒) +set matchtime=5 +" 在搜索的时候忽略大小写 +set ignorecase +" 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索) +set incsearch +" 搜索结果高亮显示 +"set hlsearch + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +"状态行显示内容 +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +"状态行显示内容 +" %F 当前文件名 +" %m 当前文件修改状态 +" %r 当前文件是否只读 +" %Y 当前文件类型 +" %{&fileformat} 当前文件编码 +" %b 当前光标处字符的 ASCII 码值 +" %B 当前光标处字符的十六进制值 +" %l 当前光标行号 +" %c 当前光标列号 +" %V 当前光标虚拟列号 (根据字符所占字节数计算) +" %p 当前行占总行数的百分比 +" %% 百分号 +" %L 当前文件总行数 +" 我的状态行显示的内容(包括文件类型和解码) +set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c +" 显示状态栏 (默认值为 1, 无法显示状态栏) +" 译注:默认情况下,只有两个以上的窗口才显示状态栏.其值定义为 +" 本选项的值影响最后一个窗口何时有状态行: +" 0: 永不 +" 1: 只有在有至少两个窗口时 +" 2: 总是 +set laststatus=2 + +function! CurDir() + let curdir = substitute(getcwd(), '/home/pat/', "~/", "g") + return curdir +endfunction + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +"菜单栏、工具栏显示与隐藏的切换 +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +set guioptions-=T +set guioptions-=m +map :if &guioptions =~# 'T' +\set guioptions-=T +\set guioptions-=m +\else +\set guioptions+=T +\set guioptions+=m +\endif + +"set shiftwidth=4 et +"set tabstop=4 et