Skip to content

Instantly share code, notes, and snippets.

@k-yamada
Created January 7, 2014 07:21
Show Gist options
  • Save k-yamada/8295776 to your computer and use it in GitHub Desktop.
Save k-yamada/8295776 to your computer and use it in GitHub Desktop.
vimrc
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 2008 Jul 02
"
" 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 then 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
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
" 個人設定
" --------
" =============== NeoBundle START ===============
set nocompatible " be iMproved
filetype off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle/'))
endif
" originalrepos on github
"NeoBundle 'Shougo/neobundle.vim'
"NeoBundle 'Shougo/vimproc'
"NeoBundle 'VimClojure'
"NeoBundle 'Shougo/vimshell'
"NeoBundle 'Shougo/unite.vim'
"NeoBundle 'Shougo/neocomplcache'
"NeoBundle 'Shougo/neocomplcache-snippets-complete'
"NeoBundle 'jpalardy/vim-slime'
"NeoBundle 'scrooloose/syntastic'
""NeoBundle 'https://bitbucket.org/kovisoft/slimv'
" neobundle"{{{
" コマンドを伴うやつの遅延読み込み
"bundle"{{{
" その他 {{{
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundleLazy 'taichouchou2/vim-endwise.git', {
\ 'autoload' : {
\ 'insert' : 1,
\ } }
" }}}
" 補完 {{{
NeoBundleLazy 'Shougo/neocomplcache', {
\ 'autoload' : {
\ 'insert' : 1,
\ }}
NeoBundleLazy 'Shougo/neosnippet', {
\ 'autoload' : {
\ 'insert' : 1,
\ }}
NeoBundle 'Shougo/neocomplcache-rsense', {
\ 'depends': 'Shougo/neocomplcache',
\ 'autoload': { 'filetypes': 'ruby' }}
NeoBundleLazy 'taichouchou2/rsense-0.3', {
\ 'build' : {
\ 'mac': 'ruby etc/config.rb > ~/.rsense',
\ 'unix': 'ruby etc/config.rb > ~/.rsense',
\ } }
" }}}
" 便利 {{{
" 範囲指定のコマンドが使えないので、tcommentのLazy化はNeoBundleのアップデートを待ちましょう...
NeoBundle 'tomtom/tcomment_vim'
NeoBundleLazy 'tpope/vim-surround', {
\ 'autoload' : {
\ 'mappings' : [
\ ['nx', '<Plug>Dsurround'], ['nx', '<Plug>Csurround'],
\ ['nx', '<Plug>Ysurround'], ['nx', '<Plug>YSurround'],
\ ['nx', '<Plug>Yssurround'], ['nx', '<Plug>YSsurround'],
\ ['nx', '<Plug>YSsurround'], ['vx', '<Plug>VgSurround'],
\ ['vx', '<Plug>VSurround']
\ ]}}
" }}}
" ruby / railsサポート {{{
NeoBundle 'tpope/vim-rails'
NeoBundleLazy 'ujihisa/unite-rake', {
\ 'depends' : 'Shougo/unite.vim' }
NeoBundleLazy 'basyura/unite-rails', {
\ 'depends' : 'Shjkougo/unite.vim' }
NeoBundleLazy 'taichouchou2/unite-rails_best_practices', {
\ 'depends' : 'Shougo/unite.vim',
\ 'build' : {
\ 'mac': 'gem install rails_best_practices',
\ 'unix': 'gem install rails_best_practices',
\ }
\ }
NeoBundleLazy 'taichouchou2/unite-reek', {
\ 'build' : {
\ 'mac': 'gem install reek',
\ 'unix': 'gem install reek',
\ },
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] },
\ 'depends' : 'Shougo/unite.vim' }
NeoBundleLazy 'taichouchou2/alpaca_complete', {
\ 'depends' : 'tpope/vim-rails',
\ 'build' : {
\ 'mac': 'gem install alpaca_complete',
\ 'unix': 'gem install alpaca_complete',
\ }
\ }
let s:bundle_rails = 'unite-rails unite-rails_best_practices unite-rake alpaca_complete'
function! s:bundleLoadDepends(bundle_names) "{{{
" bundleの読み込み
execute 'NeoBundleSource '.a:bundle_names
au! RailsLazyPlugins
endfunction"}}}
aug RailsLazyPlugins
au User Rails call <SID>bundleLoadDepends(s:bundle_rails)
aug END
" reference環境
NeoBundleLazy 'vim-ruby/vim-ruby', {
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'taka84u9/vim-ref-ri', {
\ 'depends': ['Shougo/unite.vim', 'thinca/vim-ref'],
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'skwp/vim-rspec', {
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'ruby-matchit', {
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } }
" }}}
" }}}
"}}}
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'vim-coffee-script'
" syntax + 自動compile
NeoBundle 'kchmck/vim-coffee-script'
" js BDDツール
NeoBundle 'claco/jasmine.vim'
" indentの深さに色を付ける
NeoBundle 'nathanaelkane/vim-indent-guides'
filetype plugin indent on " required!
filetype indent on
syntax on
" =============== NeoBundle END ===============
" =============== coffee START ===============
" vimにcoffeeファイルタイプを認識させる
au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee
" インデントを設定
autocmd FileType coffee setlocal sw=2 sts=2 ts=2 et
" taglistの設定 coffeeを追加
" let g:tlist_coffee_settings = 'coffee;f:function;v:variable'
" QuickRunのcoffee
" let g:quickrun_config['coffee'] = {
" \'command' : 'coffee',
" \'exec' : ['%c -cbp %s']
" \}
"------------------------------------
" vim-coffee-script
"------------------------------------
" 保存時にコンパイル
autocmd BufWritePost *.coffee silent CoffeeMake! -cb | cwindow | redraw!
"------------------------------------
" jasmine.vim
"------------------------------------
" ファイルタイプを変更
function! JasmineSetting()
au BufRead,BufNewFile *Helper.js,*Spec.js set filetype=jasmine.javascript
au BufRead,BufNewFile *Helper.coffee,*Spec.coffee set filetype=jasmine.coffee
au BufRead,BufNewFile,BufReadPre *Helper.coffee,*Spec.coffee let b:quickrun_config = {'type' : 'coffee'}
call jasmine#load_snippets()
map <buffer> <leader>m :JasmineRedGreen<CR>
command! JasmineRedGreen :call jasmine#redgreen()
command! JasmineMake :call jasmine#make()
endfunction
au BufRead,BufNewFile,BufReadPre *.coffee,*.js call JasmineSetting()
"------------------------------------
" indent_guides
"------------------------------------
" インデントの深さに色を付ける
let g:indent_guides_start_level=2
let g:indent_guides_auto_colors=0
let g:indent_guides_enable_on_vim_startup=0
let g:indent_guides_color_change_percent=20
let g:indent_guides_guide_size=1
let g:indent_guides_space_guides=1
hi IndentGuidesOdd ctermbg=235
hi IndentGuidesEven ctermbg=237
au FileType coffee,ruby,javascript,python IndentGuidesEnable
nmap <silent><Leader>ig <Plug>IndentGuidesToggle
" =============== coffee END ===============
set nobackup
set noswapfile
" for ruby
set tabstop=2
set shiftwidth=2
set expandtab
" for java
"set tabstop=4
"set shiftwidth=2
set paste
set autoindent " always set autoindenting on
colorscheme murphy
" 大文字小文字を区別
set noic
" quickrun
silent! nmap <unique> qu <Plug>(quickrun)
au QuickfixCmdPost vimgrep cw
"タブ、空白、改行を可視化
"set list
set listchars=tab-,trail:-,eol:↲,extends:»,precedes:«,nbsp:%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment