Skip to content

Instantly share code, notes, and snippets.

@nus
Last active January 7, 2018 10:59
Show Gist options
  • Save nus/a6d65aa97db39627d7e5 to your computer and use it in GitHub Desktop.
Save nus/a6d65aa97db39627d7e5 to your computer and use it in GitHub Desktop.
.vimrc
set number
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set autoindent
set termencoding=utf-8
syntax on
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
" Note: Skip initialization for vim-tiny or vim-small.
if 0 | endif
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
" Refer to |:NeoBundle-examples|.
" Note: You don't set neobundle setting in .gvimrc!
NeoBundle 'Shougo/neocomplcache.vim'
NeoBundle 'ack.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'jistr/vim-nerdtree-tabs'
NeoBundle 'tomtom/tcomment_vim'
NeoBundle 'thinca/vim-quickrun'
NeoBundle 'guns/vim-clojure-static'
NeoBundle 'tpope/vim-fireplace'
NeoBundle 'tpope/vim-classpath'
NeoBundle 'fatih/vim-go'
NeoBundle 'derekwyatt/vim-scala'
NeoBundle 'sickill/vim-monokai'
NeoBundle 'ekalinin/Dockerfile.vim'
NeoBundle 'mattn/emmet-vim'
NeoBundle 'leafgarland/typescript-vim'
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
" scrooloose/nerdtree
nnoremap <silent><C-e> :NERDTreeToggle<CR>
let NERDTreeMapOpenInTab='<Enter>'
" デフォルトでツリーを表示させる
let g:nerdtree_tabs_open_on_console_startup=1
" http://myenigma.hatenablog.com/entry/2015/12/19/081933
" virtualモードの時に * で選択範囲の文字を検索するようにする
xnoremap * :<C-u>call <SID>VSetSearch()<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch()<CR>?<C-R>=@/<CR><CR>
function! s:VSetSearch()
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, '/\'), '\n', '\\n', 'g')
let @s = temp
endfunction
" 'tomtom/tcomment_vim'
" コメントアウト用
" <C-_><C-_> 行、選択箇所をコメントをトグル
" <C-_>n 指定したftでコメントをトグル
" <C-_>s 詳細にコメント形式を指定してトグル
" <C-_>p 関数などブロック全体をトグル
" 'thinca/vim-quickrun'
" バッファーのソースコードを実行
" QuickRun.vim
" \rで実行
" QuickRun.vimでjavacだと文字化けするので対策
if !exists('g:quickrun_config')
let g:quickrun_config= {}
endif
let g:quickrun_config.java = { 'exec': ['javac -J-Dfile.encoding=UTF-8 %o %s', '%c -Dfile.encoding=UTF-8 %s:t:r %a', ':call delete("%S:t:r.class")'] }
" homebrewで入れたg++ 4.8用 c++11設定
let g:quickrun_config.cpp = {
\ 'command': 'g++-4.8',
\ 'cmdopt': '-std=c++11'
\}
" gvimでneocomplcacheを有効にするオプション
let g:neocomplcache_enable_at_startup = 1
" 選択部分を括弧でくくる
vnoremap { "zdi{<C-R>z}<ESC>
vnoremap [ "zdi[<C-R>z]<ESC>
vnoremap ( "zdi(<C-R>z)<ESC>
vnoremap " "zdi"<C-R>z"<ESC>
vnoremap ' "zdi'<C-R>z'<ESC>
" マウスを有効にする
set guioptions+=a
set mouse=a
set ttymouse=xterm2
" MacVimのツールバーを消す
set guioptions-=T
" zencoding.vimの設定
" タブのインデントをスペース4つに変更
let g:user_zen_settings = { 'indentation': ' '}
" 空白を色付け
augroup HighlightTrailingSpaces
autocmd!
autocmd VimEnter,WinEnter,ColorScheme * highlight TrailingSpaces term=underline guibg=Red ctermbg=Red
autocmd VimEnter,WinEnter * match TrailingSpaces /\s\+$/
augroup END
" ctags help
" シェルで $ ctags -R
" でタグファイル生成
" C-] 変数、メソッド名へのジャンプ
" C-t ジャンプ元へ戻る
" g C-] 複数候補がある場合に選択->ジャン
" C-w } カーソル位置の単語の定義を、プレビューウィンドウで開く
" C-w C-z プレビューウィンドウを閉じる。(:pcと同じ)
" ActionScript3.0用シンタックスハイライト
" 参考サイト: http://blog.livedoor.jp/twface/archives/139566.html
au BufNewFile,BufRead *.as set ft=actionscript
" HTML
autocmd! FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Ruby
autocmd! FileType ruby setlocal shiftwidth=2 tabstop=2 softtabstop=2
" JavaScript
autocmd! FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
" TypeScript
autocmd! FileType typescript setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Go
autocmd! FileType go setlocal noexpandtab tabstop=4 shiftwidth=4
" https://github.com/sickill/vim-monokai
colorscheme monokai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment