很菜的VIM配置

前略,前半就是vim自带的example。

syntax enable
set hlsearch
set autoindent
set nocp
set ts=4
set sw=4
set number
set encoding=utf-8

set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1

filetype plugin indent on

set grepprg=grep\ -nH\ $*
let g:tex_flavor = "latex"

set runtimepath=~/.vim,/usr/share/vim,/usr/share/vim/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after

autocmd FileType python setlocal et sta sw=4 sts=4

set completeopt=longest,menu

"cs add cscope.out .
"
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

set tags=tags;

function! UpdateCtags()
    let curdir=getcwd()
"    echo filereadable("tags")
    while !filereadable("./tags")
        cd ..
        if getcwd() == "/"
            break
        endif
    endwhile
    if filewritable("./tags")
        !ctags -R --c++-kinds=+px --fields=+iaS --extra=+q --excmd=pattern --exclude=Makefile --exclude=.
    else
        execute ":cd " . curdir
        !ctags -R --c++-kinds=+px --fields=+iaS --extra=+q --excmd=pattern --exclude=Makefile --exclude=.
    endif
"    echo getcwd() curdir
    execute ":cd " . curdir
endfunction

nmap <F10> :call UpdateCtags()<CR>

nmap <C-]> :tj <C-R>=expand("<cword>")<CR><CR>

" Tlist
"if &diff
"let Tlist_Auto_Open=0 "don't auto pen when compare two files
"else
"let Tlist_Auto_Open=1 "auto pen Tlist when open a file
"endif

"set taglist window in right, delete the following line if you don't like
let Tlist_Auto_Update=1
let Tlist_File_Fold_Auto_Close=1
"auto close Tlist when exiting file.
let Tlist_Exit_OnlyWindow = 1
nnoremap <silent> <F8> :TlistToggle<CR>

nmap <F7> :copen<CR>
nmap <F6> :cclose<CR>

let g:input_toggle = 1
function! Fcitx2en()
   let s:input_status = system("fcitx-remote")
   if s:input_status == 2
      let g:input_toggle = 1
      let l:a = system("fcitx-remote -c")
   endif
endfunction

function! Fcitx2zh()
   let s:input_status = system("fcitx-remote")
   if s:input_status != 2 && g:input_toggle == 1
      let l:a = system("fcitx-remote -o")
      let g:input_toggle = 0
   endif
endfunction

set timeoutlen=150
autocmd InsertLeave * call Fcitx2en()
"autocmd InsertEnter * call Fcitx2zh()
"set expandtab

" Set to auto read when a file is changed from the outside
set autoread

let g:doxygenToolkit_authorName="CSSlayer"
let g:doxygenToolkit_briefTag_funcName="yes"

nmap <F3>a :DoxAuthor<cr>
nmap <F3>f :Dox<cr>
nmap <F3>b :DoxBlock<cr>
nmap <F3>c O/** */<Left><Left>

" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vimrc

set expandtab

set fdm=marker

set listchars=tab:>−,trail:−
set list

function! SaveSession()
    let cwd = getcwd()
    let cwd = fnamemodify(cwd, ':t')
    if cwd != ""
        execute "mksession! ~/.vim/session/" . cwd . ".session"
        execute "wviminfo! ~/.vim/session/" . cwd . ".viminfo"
    endif
endfunction

au VimLeave * call SaveSession()

if $TERM =~ 'xterm'
    let &t_SI = "\<Esc>]50;CursorShape=1\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif

let g:DirDiffDynamicDiffText = 1

真的很土鳖的。中间有个f10一键刷新ctags。

This entry was posted in Linux. Bookmark the permalink.

8 Responses to 很菜的VIM配置

  1. Iven says:
    Firefox 6.0.2 Windows 7 x64 Edition

    其实你是在炫耀 fcitx 切换吧……

  2. adam8157 says:
    Firefox 6.0.2 GNU/Linux x64

    我的: https://github.com/adam8157/dotfiles/blob/master/.vimrc

    Ctags和cscope这种东西, 每天打开Vim之前更新一次. 缓冲打开的文件都会搜索, 不用更新…

  3. csslayer says:
    Firefox 9.0a1 Windows 7

    @Iven 不用炫耀,这部分我已经加到fcitx的手册里面了。
    http://fcitx.github.com/handbook/chapter-remote.html

  4. yetone says:
    Firefox 6.0.2 GNU/Linux

    说实话,我不知道有什么特性

  5. 依云 says:
    Firefox 6.0.2 GNU/Linux

    好多转义字符。。。。另外,python 版 fcitx.vim 最近又更新了。谁要是有需求的话也可以加上 python 2 支持。 https://github.com/lilydjwg/dotvim/blob/master/plugin/fcitx.vim

  6. vx13 says:
    Firefox 6.0 GNU/Linux x64

    上面好多广告……

  7. 右京样一 says:
    Google Chrome 14.0.835.163 GNU/Linux

    我觉得已经很好了……干脆把Vim改造成个IDE算了……

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.