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
"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 autowriteall
"set mouse=a " Enable mouse usage (all modes)

"~/.vimrc

" YouCompleteMe
set runtimepath+=~/.vim/bundle/YouCompleteMe
let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
let g:ycm_complete_in_comments = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_list_select_completion = [‘<c-n>‘, ‘<Down>‘] " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = [‘<c-p>‘, ‘<Up>‘]
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回车即选中当前项
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳转到定义处
"let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项

let g:ycm_server_python_interpreter=‘/usr/bin/python2.7‘
let g:ycm_global_ycm_extra_conf=‘~/.vim/.ycm_extra_conf.py‘

set nocompatible " be iMproved

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

"let Vundle manage Vundle
" required!
Bundle ‘indentLine/indentLine‘
Bundle ‘scrooloose/syntastic‘
Bundle ‘gmarik/vundle‘

" My bundles here:
"
" original repos on GitHub
Bundle ‘tpope/vim-fugitive‘
Bundle ‘Lokaltog/vim-easymotion‘
Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}
Bundle ‘tpope/vim-rails.git‘
" vim-scripts repos
Bundle ‘L9‘
Bundle ‘FuzzyFinder‘
" non-GitHub repos
Bundle ‘git://git.wincent.com/command-t.git‘
" Git repos on your local machine (i.e. when working on your own plugin)
Bundle ‘file:///Users/gmarik/path/to/plugin‘
" ...
Bundle ‘Valloric/YouCompleteMe‘
filetype plugin indent on " required!

"javacomplete
setlocal omnifunc=javacomplete#Complete
autocmd Filetype java set omnifunc=javacomplete#Complete
autocmd Filetype java set completefunc=javacomplete#CompleteParamsInf
inoremap <buffer> <C-X><C-U> <C-X><C-U><C-P>
inoremap <buffer> <C-S-Space> <C-X><C-U><C-P>
autocmd Filetype java,javascript,jsp inoremap <buffer> . .<C-X><C-O><C-P>

"增加横线
"autocmd InsertLeave * se nocul " 用浅色高亮当前行
"autocmd InsertEnter * se cul " 用浅色高亮当前行
set cursorline

"highlight CursorLine guibg=lightblue ctermbg=lightgray

"tab 键显示竖线
"set list lcs=tab:\|\

let g:indentLine_char=‘|‘
let g:indentLine_enabled = 1
"let g:indentLine_setColors = 0

" Source a global configuration file if available
filetype plugin indent on
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
"set encoding=prc
set encoding=utf-8
"
"显示行号
set number
"修改vim的tab,使其占4个空格
set tabstop=4
set tags=tags
set tags+=./tags "add current directory‘s generated tags file
set tags+=/usr/tags "add current directory‘s generated tags file
set laststatus=2
set softtabstop=4
set shiftwidth=4
set cindent
"set ff
set autowrite
set ruler
set previewwindow " 标识预览窗口
set showcmd " 命令行显示输入的命令
set showmode " 命令行显示vim当前模式
"--find setting--
set incsearch " 输入字符串就显示匹配点

highlight StatusLine cterm=bold ctermfg=yellow ctermbg=Darkblue

function! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "g")
return curdir
endfunction
set statusline=[%n]\ %f%m%r%h\ \|\ format:\ %{&fileformat}\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=0x%B%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\

if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif

"进行版权声明的设置
"添加或更新头
map <F4> :call TitleDet()<cr>‘s
function AddTitle()
call append(line("."),"/*=============================================================================")
call append(line(".")+1,"#")
call append(line(".")+2,"# Author: dantezhu - [email protected]")
call append(line(".")+3,"#")
call append(line(".")+4,"# QQ : 327775604")
call append(line(".")+5,"#")
call append(line(".")+6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(line(".")+7,"#")
call append(line(".")+8,"# Filename: ".expand("%:t"))
call append(line(".")+9,"#")
call append(line(".")+10,"# Description: ")
call append(line(".")+11,"#")
call append(line(".")+12,"=============================================================================*/")
" echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction

"更新最近修改时间和文件名
function UpdateTitle()
normal m‘
execute ‘/# *Last modified:/[email protected]:.*[email protected]\=strftime(":\t%Y-%m-%d %H:%M")@‘
normal ‘‘
normal mk
execute ‘/# *Filename:/[email protected]:.*[email protected]\=":\t\t".expand("%:t")@‘
execute "noh"
normal ‘k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()

call AddTitle()
return

let n=1
"默认为添加
while n < 10
let line = getline(n)
if line =~ ‘^\#\s*\S*Last\smodified:\S*.*$‘
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction

时间: 2024-08-01 22:43:28

vimrc 配置的相关文章

Linux大棚版vimrc配置

Linux大棚版vimrc配置-V2.0版本,如下: [shell] $cat .vimrc "== "Author :roc "Website:roclinux.cn "Version:2.0 "== "vim支持go语言 - 开始 "关闭文件类型检测功能 filetype off "关闭文件类型插件加载功能.文件类型缩进功能 filetype plugin indent off "增加go语言的vim相关配置路径

「小白入门」Mac vimrc -- 配置

1.打开终端 方法1:Finder - 应用程序 - 实用工具 - 终端 : 方法2:Spotlight 中搜索「terminal」或者「终端」,后回车或者单击打开: 2.在终端的用户主目录下建立.vimrc 文件(Mac 下默认没有此文件) 方法:用户主目录即为终端打开的初始界面,在此界面上输入「mkdir .vimrc」(不包括直角引号),后回车: 3.编辑.vimrc 文件,自定义 Mac 下 Vim 的配置 方法:在终端的用户主目录下输入「vim .vimrc」后回车,即可进入.vimr

ubuntu vim solarized vimrc配置

1 synatax on 2 set background=light 3 if !has('gui_running') 4 set term=xterm 5 set t_Co=256 6 endif 7 let g:solarized_termcolors = 256 8 colorscheme solarized 网上的关于这个的说明五花八门,我来个正常的 solarized.vim在colors了以后把它贴到vimrc里就可以用了 还有要dark的可以把light改为dark

vimrc配置

"******************************************************** " 一般性配置 * "******************************************************** "关闭vim一致性原则 set nocompatible "显示行号 set number "设置在编辑过程中右下角显示光标的行列信息 set ruler "在状态栏显示正在输入的命令 s

我的VIM -- vimrc配置

主要都是参考融合了网上比较热的几分VIM配置文档,加上我的使用习惯而形成的.感谢他们的奉献! 基本上每行配置上面都有注释,相信仔细看下就会明白的了. "不要使用vi的键盘模式,而是vim自己的 set nocompatible " 语法高亮 set syntax=on " 去掉输入错误的提示声音 set noeb " 在处理未保存或只读文件的时候,弹出确认 set confirm " 自动缩进 set autoindent set cindent &quo

我的 .vimrc 配置

" .vimrc " See: http://vimdoc.sourceforge.net/htmldoc/options.html for details " For multi-byte character support (CJK support, for example): " set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,gb18030,latin1 set tabstop=4 set s

linux下root用户和tarena用户vimrc配置

设置vim自动缩进,行号,tab键宽度 如果是root超级用户,他的主目录是: /root ,打开文件vim的配置文件.vimrc 如果是tarena用户,他的主目录是:/home/tarena 打开文件vim的配置文件.vimrc set nu  ------------------ 设置行号 set autoindent  ------------- 自动缩进 set cindent   -------------- C语言风格的自动缩进 set tabstop=4     --------

备份一下在用的.vimrc配置

syntax on colorscheme 颜色主题名称 set number set autoread set cindent set expandtab set shiftwidth=4 set tabstop=4 set softtabstop=4 set fileencodings=utf-8,gbk let g:loaded_matchparen=1 let g:loaded_matchparen=1是为了去掉自动高亮匹配括号的功能,因为这个功能容易让人看不清光标所在位置 个人比较喜欢

Vim vimrc配置

set nocompatible set encoding=utf-8 syntax on set autoindent set smartindent set tabstop=4 set softtabstop=4 set expandtab set ai! set cindent shiftwidth=4 set number set ruler set laststatus=2 set statusline=%<%F\ [%l] 参考文献:cnblogs.com/lovevivi/arch