Created
December 23, 2013 13:51
-
-
Save hogesuke/8097443 to your computer and use it in GitHub Desktop.
vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" An example for a vimrc file. | |
" | |
" Maintainer: Bram Moolenaar <Bram@vim.org> | |
" Last change: 2008 Dec 17 | |
" | |
" To use it, copy it to | |
" for Unix and OS/2: ~/.vimrc | |
" for Amiga: s:.vimrc | |
" for MS-DOS and Win32: $VIM\_vimrc | |
" for OpenVMS: sys$login:.vimrc | |
" When started as "evim", evim.vim will already have done these settings. | |
if v:progname =~? "evim" | |
finish | |
endif | |
" Use Vim settings, rather than Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
if has("vms") | |
set nobackup " do not keep a backup file, use versions instead | |
else | |
set backup " keep a backup file | |
endif | |
set history=50 " keep 50 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries | |
" let &guioptions = substitute(&guioptions, "t", "", "g") | |
" Don't use Ex mode, use Q for formatting | |
map Q gq | |
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, | |
" so that you can undo CTRL-U after inserting a line break. | |
inoremap <C-U> <C-G>u<C-U> | |
" In many terminal emulators the mouse works just fine, thus enable it. | |
if has('mouse') | |
set mouse=a | |
endif | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
set hlsearch | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
" Enable file type detection. | |
" Use the default filetype settings, so that mail gets 'tw' set to 72, | |
" 'cindent' is on in C files, etc. | |
" Also load indent files, to automatically do language-dependent indenting. | |
filetype plugin indent on | |
" Put these in an autocmd group, so that we can delete them easily. | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
" Also don't do it when the mark is in the first line, that is the default | |
" position when opening a file. | |
autocmd BufReadPost * | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
augroup END | |
else | |
set autoindent " always set autoindenting on | |
endif " has("autocmd") | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. | |
" Only define it when not defined already. | |
if !exists(":DiffOrig") | |
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
endif | |
""""""""""""""""""""""""""" | |
" <Leader>の設定 | |
""""""""""""""""""""""""""" | |
let mapleader=" " | |
""""""""""""""""""""""""""" | |
"キーバインド | |
""""""""""""""""""""""""""" | |
"挿入モードでのカーソル移動 | |
inoremap <C-j> <Down> | |
inoremap <C-k> <Up> | |
inoremap <C-h> <Left> | |
inoremap <C-l> <Right> | |
""""""""""""""""""""""""""" | |
"タブ幅の設定 | |
""""""""""""""""""""""""""" | |
au BufNewFile,BufRead *.* set nowrap tabstop=4 shiftwidth=4 | |
au BufNewFile,BufRead *.rb set nowrap tabstop=2 shiftwidth=2 | |
au BufNewFile,BufRead *.ejs set nowrap tabstop=2 shiftwidth=2 | |
au BufNewFile,BufRead *.html set nowrap tabstop=2 shiftwidth=2 | |
au BufNewFile,BufRead *.js set nowrap tabstop=2 shiftwidth=2 | |
"""""""""""""""""" | |
""neobundle | |
"""""""""""""""""" | |
set nocompatible " Be iMproved | |
filetype off | |
if has('vim_starting') | |
set runtimepath+=~/.vim/bundle/neobundle.vim/ | |
call neobundle#rc(expand('~/.vim/bundle/')) | |
endif | |
" GitHubリポジトリにあるプラグインを利用する | |
NeoBundle 'Shougo/neocomplcache.vim' | |
NeoBundle 'Shougo/neosnippet.vim' | |
NeoBundle 'Shougo/unite.vim' | |
NeoBundle 'Shougo/vimfiler.vim' | |
"GitHub以外のGitリポジトリにあるプラグインを利用する | |
"例:NeoBundle 'git://git.wincent.com/command-t.git' | |
" vim-scripts リポジトリにあるプラグインを利用する | |
"例:NeoBundle 'surround.vim' | |
"Git以外のリポジトリにあるプラグインを利用する | |
"例:NeoBundle 'http://svn.macports.org/repository/macports/contrib/mpvim/' | |
"例:NeoBundle 'https://bitbucket.org/ns9tks/vim-fuzzyfinder' | |
" Let NeoBundle manage NeoBundle | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
" Recommended to install | |
" After install, turn shell ~/.vim/bundle/vimproc, (n,g)make -f your_machines_makefile | |
NeoBundle 'Shougo/vimproc', { | |
\ 'build' : { | |
\ 'windows' : 'make -f make_mingw32.mak', | |
\ 'cygwin' : 'make -f make_cygwin.mak', | |
\ 'mac' : 'make -f make_mac.mak', | |
\ 'unix' : 'make -f make_unix.mak', | |
\ }, | |
\ } | |
filetype plugin indent on " Required! | |
" Brief help | |
" :NeoBundleList - list configured bundles | |
" :NeoBundleInstall(!) - install(update) bundles | |
" :NeoBundleClean(!) - confirm(or auto-approve) removal of unused bundles | |
" Installation check. | |
NeoBundleCheck | |
""""""""""""""""""""""""""" | |
" Unite.vimキーバインド | |
""""""""""""""""""""""""""" | |
" The prefix key. | |
nnoremap [unite] <Nop> | |
nmap <Leader>f [unite] | |
" unite.vim keymap | |
nnoremap [unite]u :<C-u>Unite -no-split<Space> | |
nnoremap <silent> [unite]f :<C-u>Unite<Space>buffer<CR> | |
nnoremap <silent> [unite]b :<C-u>Unite<Space>bookmark<CR> | |
nnoremap <silent> [unite]m :<C-u>Unite<Space>file_mru<Space>-default-action=tabopen<CR> | |
nnoremap <silent> [unite]r :<C-u>UniteWithBufferDir file<Space>-default-action=tabopen<CR> | |
nnoremap <silent> ,vr :UniteResume<CR> | |
" vinarise | |
let g:vinarise_enable_auto_detect = 1 | |
" unite-build map | |
nnoremap <silent> ,vb :Unite build<CR> | |
nnoremap <silent> ,vcb :Unite build:!<CR> | |
nnoremap <silent> ,vch :UniteBuildClearHighlight<CR> | |
""""""""""""""""""""""""""" | |
" VimFiler | |
""""""""""""""""""""""""""" | |
nnoremap <silent> <Space>j :VimFiler<CR> | |
""""""""""""""""""""""""""" | |
" neocomplcache | |
""""""""""""""""""""""""""" | |
" Disable AutoComplPop. | |
let g:acp_enableAtStartup = 0 | |
" Use neocomplcache. | |
let g:neocomplcache_enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplcache_enable_smart_case = 1 | |
" Set minimum syntax keyword length. | |
let g:neocomplcache_min_syntax_length = 3 | |
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' | |
" Define dictionary. | |
let g:neocomplcache_dictionary_filetype_lists = { | |
\ 'default' : '' | |
\ } | |
" Plugin key-mappings. | |
inoremap <expr><C-g> neocomplcache#undo_completion() | |
inoremap <expr><C-l> neocomplcache#complete_common_string() | |
" Recommended key-mappings. | |
" <CR>: close popup and save indent. | |
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> | |
function! s:my_cr_function() | |
return neocomplcache#smart_close_popup() . "\<CR>" | |
endfunction | |
" <TAB>: completion. | |
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
" <C-h>, <BS>: close popup and delete backword char. | |
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" | |
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" | |
inoremap <expr><C-y> neocomplcache#close_popup() | |
inoremap <expr><C-e> neocomplcache#cancel_popup() | |
""""""""""""""""""""""""""" | |
"各種設定 | |
""""""""""""""""""""""""""" | |
"カラースキーマを設定 | |
colorscheme desert | |
"新しい行のインデントを現在行と同じにする | |
set autoindent | |
"バックアップファイルを作るディレクトリ | |
set backupdir=$HOME/vimbackup | |
"ファイル保存ダイアログの初期ディレクトリをバッファファイル位置に設定 | |
set browsedir=buffer | |
"クリップボードをWindowsと連携 | |
set clipboard=unnamed | |
"Vi互換をオフ | |
"set nocompatible | |
"スワップファイル用のディレクトリ | |
set directory=$HOME/vimbackup | |
"タブの代わりに空白文字を挿入する | |
set expandtab | |
"変更中のファイルでも、保存しないで他のファイルを表示 | |
set hidden | |
"インクリメンタルサーチを行う | |
set incsearch | |
"タブ文字、行末など不可視文字を表示する | |
set lcs=tab:>.,eol:↲,extends:»,precedes:« | |
set list | |
highlight SpecialKey cterm=NONE ctermfg=gray guifg=gray | |
"全角スペースをハイライトさせる。 | |
function! JISX0208SpaceHilight() | |
syntax match JISX0208Space " " display containedin=ALL | |
highlight JISX0208Space term=underline ctermbg=LightCyan | |
endf | |
"行番号を表示する | |
set number | |
"シフト移動幅 | |
set shiftwidth=4 | |
"閉じ括弧が入力されたとき、対応する括弧を表示する | |
set showmatch | |
"検索時に大文字を含んでいたら大/小を区別 | |
set smartcase | |
"新しい行を作ったときに高度な自動インデントを行う | |
set smartindent | |
"行頭の余白内で Tab を打ち込むと、'shiftwidth' の数だけインデントする。 | |
set smarttab | |
"ファイル内の <Tab> が対応する空白の数 | |
set tabstop=4 | |
"カーソルを行頭、行末で止まらないようにする | |
set whichwrap=b,s,h,l,<,>,[,] | |
"検索をファイルの先頭へループしない | |
set nowrapscan | |
"折り返さずに表示する | |
set nowrap | |
"ヤンクしたものをクリップボードに入れる | |
:set guioptions+=a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment