vim構成の詳細

12245 ワード

vimプロファイル、ハイライト+自動インデント+行番号+折りたたみ+最適化
 
コードcopyをユーザーディレクトリの下に新しいファイルを作成します.vimrc
保存すれば有効になります.すべてのユーザーを有効にするには/etc/vimrcを変更します(まずcpを1部お勧めします)
"=========================================================================
" DesCRiption: vimrc ,for Linux/Windows, GUI/Console
"
" Last Change: 2010 08 02 15 13
"
" Version: 1.80
"
"=========================================================================

set nocompatible " vi
syntax on "
colorscheme molokai "
set number "
set cursorline "
set ruler "
set shiftwidth=4 " << >> 4
set softtabstop=4 " 4
set tabstop=4 " tab 4
set nobackup "
set autochdir "
filetype plugin indent on "
set backupcopy=yes "
set ignorecase smartcase " ,
set nowrapscan "
set incsearch "
set hlsearch "
set noerrorbells "
set novisualbell "
set t_vb= "
" set showmatch " ,
" set matchtime=2 "
set magic "
set hidden " , vim
set guioptions-=T "
set guioptions-=m "
set smartindent "
set backspace=indent,eol,start
" Delete
set cmdheight=1 " 1
set laststatus=2 " ( 1, )
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
"
set foldenable "
set foldmethod=syntax "
set foldcolumn=0 "
setlocal foldlevel=1 "
" set foldclose=all "
" nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
"


" return OS type, eg: windows, or linux, mac, et.st..
function! MySys()
if has("win16") || has("win32") || has("win64") || has("win95")
return "windows"
elseif has("unix")
return "linux"
endif
endfunction

" $VIMFILES
if MySys() == "windows"
let $VIMFILES = $VIM.'/vimfiles'
elseif MySys() == "linux"
let $VIMFILES = $HOME.'/.vim'
endif

" doc
let helptags=$VIMFILES.'/doc'

"
if has("win32")
set guifont=Inconsolata:h12:cANSI
endif

"
if has("multi_byte")
" UTF-8
set encoding=utf-8
set termencoding=utf-8
set formatoptions+=mM
set fencs=utf-8,gbk

if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif

if has("win32")
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif

" Buffers !
nnoremap <C-RETURN> :bnext<CR>
nnoremap <C-S-RETURN> :bprevious<CR>

" Tab !
nnoremap <C-TAB> :tabnext<CR>
nnoremap <C-S-TAB> :tabprev<CR>

" tab
" map tn :tabnext<cr>
" map tp :tabprevious<cr>
" map td :tabnew .<cr>
" map te :tabedit
" map tc :tabclose<cr>

" , ,
" , <c-w><c-w>k, , <c-k>,
" .
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" ( )
nnoremap <leader>1 :set filetype=xhtml<CR>
nnoremap <leader>2 :set filetype=css<CR>
nnoremap <leader>3 :set filetype=javascript<CR>
nnoremap <leader>4 :set filetype=php<CR>

" set fileformats=unix,dos,mac
" nmap <leader>fd :se fileformat=dos<CR>
" nmap <leader>fu :se fileformat=unix<CR>

" use Ctrl+[l|n|p|cc] to list|next|previous|jump to count the result
" map <C-x>l <ESC>:cl<CR>
" map <C-x>n <ESC>:cn<CR>
" map <C-x>p <ESC>:cp<CR>
" map <C-x>c <ESC>:cc<CR>


" Tohtml CSS html
" syntax/2html.vim, :runtime! syntax/2html.vim
let html_use_css=1

" Python , tab
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
autocmd FileType python map <F12> :!python %<CR>

" Ctrl+c
vmap <C-c> "+y

" javascript
let b:javascript_fold=1
" javascript dom、html css
let javascript_enable_domhtmlcss=1
" ~/.vim/dict/
autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict
autocmd filetype css set dictionary=$VIMFILES/dict/css.dict
autocmd filetype php set dictionary=$VIMFILES/dict/php.dict

"-----------------------------------------------------------------
" plugin - bufexplorer.vim Buffers
" \be
" \bv \bs
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - taglist.vim , ctags
" F4 taglist
"-----------------------------------------------------------------
if MySys() == "windows" " windows ctags
let Tlist_Ctags_Cmd = '"'.$VIMRUNTIME.'/ctags.exe"'
elseif MySys() == "linux" " windows ctags
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
endif
nnoremap <silent><F4> :TlistToggle<CR>
let Tlist_Show_One_File = 1 " tag,
let Tlist_Exit_OnlyWindow = 1 " taglist , vim
let Tlist_Use_Right_Window = 1 " taglist
let Tlist_File_Fold_Auto_Close=1 "
let Tlist_Auto_Open = 0
let Tlist_Auto_Update = 1
let Tlist_Hightlight_Tag_On_BufEnter = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Process_File_Always = 1
let Tlist_Display_Prototype = 0
let Tlist_Compact_Format = 1


"-----------------------------------------------------------------
" plugin - mark.vim tags , 。
" \m mark or unmark the word under (or before) the cursor
" \r manually input a regular expression. .
"
clear this mark (i.e. the mark under the cursor), or clear all highlighted marks .
" \* MarkWord \# MarkWord
" \/ MarkWords \? MarkWords
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - NERD_tree.vim
" :ERDtree NERD_tree :NERDtreeClose NERD_tree
" o t
" T !
" p P
" K J
" u m ( 、 、 )
" r R
"-----------------------------------------------------------------
" F3 NERDTree
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC>:NERDTreeToggle<CR>


"-----------------------------------------------------------------
" plugin - NERD_commenter.vim ,
" [count],cc count (7,cc)
" [count],cu count (7,cu)
" [count],cm count (7,cm)
" ,cA /* */, 。 。
" :count ,
"-----------------------------------------------------------------
let NERDSpaceDelims=1 "
let NERDCompactSexyComs=1 "


"-----------------------------------------------------------------
" plugin - DoxygenToolkit.vim ,
"-----------------------------------------------------------------
let g:DoxygenToolkit_authorName="Asins - asinsimple AT gmail DOT com"
let g:DoxygenToolkit_briefTag_funcName="yes"
map <leader>da :DoxAuthor<CR>
map <leader>df :Dox<CR>
map <leader>db :DoxBlock<CR>
map <leader>dc a /* */<LEFT><LEFT><LEFT>


"-----------------------------------------------------------------
" plugin – ZenCoding.vim ,HTML
" :http://github.com/mattn/zencoding-vim
" :http://nootn.com/blog/Tool/23/
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin – checksyntax.vim JavaScript
" F5
"-----------------------------------------------------------------
let g:checksyntax_auto = 0 "


"-----------------------------------------------------------------
" plugin - NeoComplCache.vim
"-----------------------------------------------------------------
let g:AutoComplPop_NotEnableAtStartup = 1
let g:NeoComplCache_EnableAtStartup = 1
let g:NeoComplCache_SmartCase = 1
let g:NeoComplCache_TagsAutoUpdate = 1
let g:NeoComplCache_EnableInfo = 1
let g:NeoComplCache_EnableCamelCaseCompletion = 1
let g:NeoComplCache_MinSyntaxLength = 3
let g:NeoComplCache_EnableSkipCompletion = 1
let g:NeoComplCache_SkipInputTime = '0.5'
let g:NeoComplCache_SnippetsDir = $VIMFILES.'/snippets'
" <TAB> completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" snippets expand key
imap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)
smap <silent> <C-e> <Plug>(neocomplcache_snippets_expand)


"-----------------------------------------------------------------
" plugin - matchit.vim %
" % g%
" [% ]%
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin - vcscommand.vim %
" SVN/git
"-----------------------------------------------------------------


"-----------------------------------------------------------------
" plugin – a.vim
"-----------------------------------------------------------------