./vimrc编辑,根目录下 vim ~/.vimrc

"config begin
"impressive : http://amix.dk/vim/vimrc.html

"==========================================
" general
"==========================================
set history=1000            " history存储长度

filetype on                 " 检测文件类型
filetype indent on          " 针对不同的文件类型采用不同的缩进格式
filetype plugin on          " 允许插件
filetype plugin indent on   " 启动自动补全

set nocompatible            " 非兼容vi模式
set autoread                " 文件修改之后自动载入
set shortmess=atI           " 启动的时候不显示那个援助索马里儿童的提示

set nobackup                " 取消备份。
set nowb
set noswapfile

set paste                   " 粘贴时保持格式
set mouse-=a                " 在所有的模式下面打开鼠标
set selection=exclusive
set selectmode=mouse,key

set noerrorbells            " 去掉输入错误的提示声音
set novisualbell


"==========================================
" show and format
"==========================================
set number                  " 显示行号
set wrap                    " 换行

set showmatch               " 括号配对情况
set matchtime=3             " 括号匹配高亮时间

"==========================================
" search
"==========================================
set hlsearch                " 高亮search命中的文本
set ignorecase              " 搜索时忽略大小写
set incsearch               " 随着键入即时搜索
set smartcase               " 有一个或以上大写字母时仍大小写敏感

set foldenable              " 代码折叠
set foldmethod=manual       " 手动折叠
"set foldcolumn=4           " 在左侧显示折叠的层次

扫描二维码关注公众号,回复: 4960892 查看本文章

set tabstop=4               " 设置Tab键的宽度
set shiftwidth=4            " 设置缩进长度
set expandtab               " 将Tab自动转化成空格(Tab=Ctrl+V + Tab)
retab
set softtabstop=4           " 按退格键时可以一次删掉4个空格

set autoindent              " 自动缩进
set smartindent             " 智能缩进

set listchars=tab:.\ ,trail:.   " 将空格替换成.显示
set list                    " 开启显示

set backspace=eol,start,indent  " 设置backspace
set whichwrap+=<,>,h,l      " 允许backspace和光标键跨越行边界

"==========================================
" encode
"==========================================
set fileencodings=gb2312,utf-8
set fileencoding=gb2312
set termencoding=utf-8

"==========================================
" status
"==========================================
set ruler                   " 显示当前的行号列号
set showcmd                 " 在状态栏显示正在输入的命令
set so=7                    " 上下滚动,始终在中间
"set cursorline             " 突出显示当前行

set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%)
set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")}     " 设置状态栏信息
set laststatus=2            " 总显示状态行

"==========================================
" colors and fonts
"==========================================
syntax on                   " 开启语法高亮
colorscheme torte           " 配色方案:darkblue,desert,industry,morning,torte
set background=dark         " 设置背景色
set t_Co=256                " vim为256色

" 设置GUI模式下的选项
if has("gui_running")
    set guioptions-=T
    set guioptions+=e
    set t_Co=256
    set guitablabel=%M\ %t
endif
set guifont=Monaco:h20      " 设置字体和字号

"==========================================
" file encode
"==========================================
set fileencoding=utf8       " 设置新文件的编码为UTF-8
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

set ffs=unix,dos,mac        " 设置默认文件类型
set ff=unix                 " 文件格式转为unix
set formatoptions+=m        " 如遇Unicode值大于255的文本,不必等到空格再折行
set formatoptions+=B        " 合并两行中文时,不在中间加空格

"==========================================
" others
"==========================================
autocmd! bufwritepost _vimrc source %   " vimrc文件修改之后自动加载(windows)
autocmd! bufwritepost .vimrc source %   " vimrc文件修改之后自动加载(linux)

set completeopt=longest,menu            " 自动完成
set wildmenu                            " 增强模式中的命令行自动完成操作
set wildignore=*.o,*~,*.pyc             " 忽略编译文件

set cc=80                               " 设置宽度提示线
set magic                               " 设置正则表达式元字符默认列表

" 窗口切换
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k

" 打开文件时光标定位在最后一次编辑的位置
autocmd BufReadPost *
            \ if line("'\"") > 0 && line("'\"") <= line("$") |
            \ exe "normal! g`\"" |
            \ endif

"==========================================
" python
"==========================================
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab    " Python文件的一般设置
autocmd FileType python set omnifunc=pythoncomplete#Complete    " 自动补全配置

"==========================================
" ctags & taglist
"==========================================
set tags=tags                       " 设置tags
let Tlist_Auto_Open=0               " 默认打开Tlist
let Tlist_Sort_Type="name"          " 按照名称排序
let Tlist_Use_Right_Window=1        " 在右侧显示窗口
let Tlist_Compart_Format=1          " 压缩方式
let Tlist_Exit_OnlyWindow=1         " 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_File_Fold_Auto_Close=0    " 不要关闭其他文件的tags
let Tlist_Enable_Fold_Column=0      " 不要显示折叠树
let Tlist_Show_One_File=1           " 不同时显示多个文件的tag,只显示当前文件的
let Tlist_WinWidth=40               " 设置Tlist窗口大小

"==========================================
" cscope
"==========================================
if has("cscope")
    set cscopequickfix=s-,c-,d-,i-,t-,e-    " 设定可以使用 quickfix 窗口来查看 cscope 结果
    set cscopetag                           " 使支持用 Ctrl+]  和 Ctrl+t 快捷键在代码间跳转
    set csto=0                              " 如果你想反向搜索顺序设置为1
    if filereadable("cscope.out")           " 在当前目录中添加任何数据库
        cs add cscope.out
    elseif $CSCOPE_DB != ""                 " 否则添加数据库环境中所指出的
        cs add $CSCOPE_DB
    endif
    set cscopeverbose
    "快捷键设置
    nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif

"==========================================
" program info
"==========================================
map <F4> :call TitleDet() <cr>
function! AddTitle()
    call append(0,"/*******************************************************")
    call append(1," *")
    call append(2," *  Author        : Mr.Gao")
    call append(3," *  Email         : [email protected]")
    call append(4," *  Filename      : ".expand("%:t"))
    call append(5," *  Last modified : ".strftime("%Y-%m-%d %H:%M"))
    call append(6," *  Description   : ")
    call append(7," *")
    call append(8," * *****************************************************/")
    echohl WarningMsg | echo "Successful in adding copyright." | echohl None
endfunction

function! UpdateTitle()
    normal m'
    execute '/*\s*Last modified\s*:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M")@'
    normal ''
    normal mk
    execute '/*\s*Filename\s*:/s@:.*$@\=": ".expand("%:t")@'
    execute "noh"
    normal 'k
    echohl WarningMsg | echo "Successful in updating the copyright." | echohl None
endfunction

function! TitleDet()
    let n=1
    while n < 10
        let line = getline(n)
        if line =~ '\s*\S\s*Last\smodified\s*:\s*\S*.*$'
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction

map <F9> : python -m json.tool<CR>

set cscopequickfix=s-,c-,d-,i-,t-,e-
 

猜你喜欢

转载自blog.csdn.net/Gu_zhi/article/details/85275109