私の軽度のカスタマイズvim


詳細
vimの学習曲線は急で長いが、その機能とカスタマイズ性はあまりにも強く、熟練したユーザーに高度にカスタマイズされたvimを加えることで高い効率を達成することができ、vimの様々な高級機能を熟練して運用することはクールなことであり、近期間で他のエディタを試さず、徐々に自分に合ったvimを作ることにした.以下に記録するのは、私自身が役に立つと思っているか、忘れやすいか、この文章の内容も徐々に豊かになります.
テクニック:
gd
変数宣言の場所にジャンプ
+ ]
定義された場所にジャンプするにはctagsがtagファイルを事前に生成する必要があります
+ o
前の位置に戻る
5 + + ^
5番bufferにジャンプ
+ PgUp/PgDn
tab間で踊る
:ls
bufferのリスト
+ g
現在の編集ファイルの現在のカーソルの行位置とファイルのステータス情報を表示
:r FILENAME
現在のファイルに別のファイルの内容を挿入
J
2行をつなぎ合わせる
f/F
単一文字検索コマンド、最も有用な移動コマンドの1つ、「fx」コマンドは、ローの文字xを前に検索します.「F」コマンドは、左に検索するために使用されます.
tx
コマンドは「fx」と似ていますが、ターゲット文字の前の文字にカーソルを移動するだけです.
H,M,L
現在の視野に移動したホーム、Middle、Lastのそれぞれを表します.
:qall
すべて終了
:wqall
すべて保存して終了
vimでの置換:
%
全文一致を表す
:s/old/new/g
現在の行のすべてのoldをnewに置き換えます.
:%s/old/new/
全文のoldをnewに置き換えるが、各行は最初の単語だけを置き換えることを表す.
:%s/old/new/g
全文に現れたすべてのoldをnewに置き換えることを表す.
%s/old/new/gc
全文置換、置換前の問い合わせ;d g/china/dを削除する.
私のvimrcは以下の通りです.

"      VIM
" JH Gao 
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" =>     
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off
set nobackup
set nowb
set noswapfile

set autoread        " Set to auto read when a file is changed from the outside
set hid             "Change buffer - without saving

" map leader   
" With a map leader it's possible to do extra key combinations
" like w saves the current file
let mapleader = ","
let g:mapleader = ","

set showcmd         " Show (partial) command in status line.
set showmatch       " Show matching brackets.
"set ignorecase     " Do case insensitive matching
set linebreak       "     
set smartcase       " Do smart case matching
set incsearch        "            
set hlsearch        " high light search results
set autowrite       "          
"set hidden         " Hide buffers when they are abandoned
"set mouse=a        " Enable mouse usage (all modes)
set nu

"--     --
set title           " show title in console title bar
set laststatus=2 "              ;  1                       ;0             
set ruler            "   ,              ,    。           。        ,       。  ,            。

"     
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936

"                    
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" =>     
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
runtime! debian.vim
syntax on
set background=dark
colorscheme default  "      ,vim          /usr/share/vim/vim73/colors  
" Python       
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" =>     tabs and indent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab       "  :re   tab     
set autoindent
set ai              "Auto indent
set si              "Smart indet
set wrap            "Wrap lines

"        , python    
func! DeleteTrailingWS()
  exe "normal mz"
  %s/\s\+$//ge
  exe "normal `z"
endfunc

autocmd BufWrite *.py,*.t2t,*.sh :call DeleteTrailingWS()

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" =>  tabs windows    
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Tab  ,       ','
map tn :tabnew
map te :tabedit
map tc :tabclose
map tm :tabmove

"    tab     ,              :)
nnoremap  :tabedit

"     buffer  tab    
let notabs = 1
nnoremap   :let notabs=!notabs:if notabs:tabo:else:tab ball:tabn:endif

"   ,   ,`       /   tab
set switchbuf=usetab
nnoremap  :sbnext
nnoremap ` :sbprevious

"   ,1 ,2 ,3      tab
map 1 1gt
map 2 2gt
map 3 3gt
map 4 4gt
map 5 5gt
map 6 6gt
map 7 7gt
map 8 8gt
map 9 9gt


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cope,             
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Do :help cope if you are unsure what cope is. It's super useful!
map cc :botright cope
map n :cn
map p :cp

""""""""""""""""""""""""""""""
" =>     
""""""""""""""""""""""""""""""

set autoindent

"  vundle     
set nocompatible
filetype off " required!

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

" Use Vundle to Manage Vundle
Bundle 'gmarik/vundle'
"       
Bundle 'genutils'
Bundle 'taglist.vim'
Bundle 'TaskList.vim'
Bundle 'django.vim'
Bundle 'jQuery'
Bundle 'a-new-txt2tags-syntax'
Bundle 'python.vim'
Bundle 'Syntastic'
Bundle 'pyflakes'
Bundle 'L9'
Bundle 'FuzzyFinder'

filetype plugin indent on

" Syntastic
let g:syntastic_python_checker = 'pylint'
"let g:syntastic_python_checker_args = '--rcfile /etc/pylint.conf -d C0301'
"let g:syntastic_quiet_warnings=1

" NERDTree,        vundle  
let NERDTreeShowBookmarks = 1
"  F3        
map   :NERDTreeFind

" FuzzyFinder
map F :FufFile
map f :FufTaggedFile
map g :FufTag
map b :FufBuffer

" txt2tags
au BufNewFile,BufRead *.t2t set ft=txt2tags

"  ctags   taglist
"   F4    tag  ,   taglist
map  :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
imap  :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
set tags=tags
set tags+=./tags "add current directory's generated tags file
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_Show_One_File = 1            "          tag,        
let Tlist_Exit_OnlyWindow = 1          "  taglist         ,   vim
let Tlist_Show_One_File=0              " taglist               
let Tlist_File_Fold_Auto_Close=1       "     ,        
let Tlist_Use_Right_Window = 1         "        taglist  
let Tlist_Process_File_Always = 1      "aglist        tag,  taglist       
"   F9    /  taglist  
map   :TlistToggle

" pyflakes
" map   :call pyflakes()

" python.vim
" Shortcuts:
"   ]t      -- Jump to beginning of block
"   ]e      -- Jump to end of block
"   ]v      -- Select (Visual Line Mode) block
"   ]<      -- Shift block to left
"   ]>      -- Shift block to right
"   ]#      -- Comment selection
"   ]u      -- Uncomment selection
"   ]c      -- Select current/previous class
"   ]d      -- Select current/previous function
"   ]   -- Jump to previous line with the same/lower indentation
"   ] -- Jump to next line with the same/lower indentation

" TaskList.vim
" t  TODO list window

"""""""""""""""""""""""""""""""""""""""""""""
" =>        (python, bash, lua, perl)
"""""""""""""""""""""""""""""""""""""""""""""

"  python shell          ,                   
map  :call AutoRun(input('argv : '))

func AutoRun(par)
    let par = a:par
    exec "w"
    if &filetype == 'sh'
        let cmd = "!bash % ".par
    elseif &filetype == 'python'
        let cmd = "!python % ".par
    elseif &filetype == 'perl'
        let cmd = "!perl % ".par
    elseif &filetype == 'lua'
        let cmd = "!lua % ".par
    endif
    exec cmd
endfunc