Skip to content

Instantly share code, notes, and snippets.

@nenjiru
Created March 16, 2015 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nenjiru/942c9f9c755f3eede05e to your computer and use it in GitHub Desktop.
Save nenjiru/942c9f9c755f3eede05e to your computer and use it in GitHub Desktop.
vimrc
""""""""""""""""""""""""""""""""""""""""
" プラグイン管理
""""""""""""""""""""""""""""""""""""""""
" MacVimを初期化した場合は、以下
" mkdir -p ~/.vim/bundle
" git clone https://github.com/Shougo/neobundle.vim
" git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
" cd ~/.vim/bundle/vimproc.vim
" make
"
":NeoBundleInstall インストール
":NeoBundleInstall! アップデート
"プラグインの削除 .vimrcから削除後 :NeoBundleClean
set nocompatible
filetype off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
call neobundle#end()
endif
" Plugin
NeoBundle 'Shougo/neobundle.vim.git'
NeoBundle 'Shougo/neocomplcache.git'
NeoBundle 'Shougo/neomru.vim'
NeoBundle 'Shougo/unite.vim.git'
NeoBundle 'Shougo/vimfiler.git'
NeoBundle 'Shougo/vimproc.git'
NeoBundle 'Shougo/vimshell.git'
NeoBundle 'scrooloose/nerdcommenter.git'
NeoBundle 'scrooloose/nerdtree.git'
NeoBundle 'itchyny/lightline.vim'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'majutsushi/tagbar'
NeoBundle 'vim-scripts/sudo.vim.git'
NeoBundle 'junegunn/vim-easy-align'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'kana/vim-submode'
NeoBundle 'vim-scripts/TaskList.vim'
" Syntax
NeoBundle 'lasticboy/vim-markdown'
NeoBundle 'mattn/emmet-vim.git'
NeoBundle 'mattn/jscomplete-vim'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'hail2u/vim-css3-syntax.git'
NeoBundle 'digitaltoad/vim-jade' "via https://github.com/digitaltoad/vim-jade
NeoBundle 'wavded/vim-stylus' "via https://github.com/wavded/vim-stylus
NeoBundle 'sudar/vim-arduino-syntax'
" AS3
" http://www.vim.org/scripts/script.php?script_id=1585
" Color scheme
NeoBundle 'tomasr/molokai'
filetype plugin on
filetype indent on
"""""""""""""""""""""""""""""""""""""""""
"" プラグイン設定
"""""""""""""""""""""""""""""""""""""""""
syntax on
" ZenCoding(emmet)のキーバインド変更
let g:user_emmet_expandabbr_key = '<C-e>'
let g:use_emmet_complete_tag = 1
" Neocomplcache 補完を使う
let g:neocomplcache_enable_at_startup=1
" DOMとMozilla関連とES6のメソッドを補完
let g:jscomplete_use = ['dom', 'moz', 'es6th']
" Unite
let g:unite_enable_start_insert = 1
let g:unite_enable_split_vertically = 0
let g:unite_winwidth = 40
" ブックマークを最初から表示
let g:NERDTreeShowBookmarks=1
" カラースキーム
colorscheme molokai
let g:molokai_original = 1
let g:rehash256 = 1
""""""""""""""""""""""""""""""""""""""""
" ファイルタイプ
""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.md set filetype=markdown
autocmd BufNewFile,BufRead *.txt set filetype=markdown
autocmd BufNewFile,BufRead *.js set filetype=javascript syntax=javascript
autocmd BufNewFile,BufRead *.js set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.json set filetype=js syntax=javascript
autocmd BufNewFile,BufRead *.jade set filetype=jade
autocmd BufNewFile,BufRead *.jade set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.styl set filetype=stylus
autocmd BufNewFile,BufRead *.styl set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.as set filetype=actionscript
autocmd BufNewFile,BufRead *.as set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
autocmd BufNewFile,BufRead *.coffee set tabstop=4 shiftwidth=4 expandtab
autocmd BufNewFile,BufRead *.ino set filetype=arduino syntax=arduino
autocmd BufNewFile,BufRead *.ino set tabstop=4 shiftwidth=4 expandtab
autocmd FileType arduino setlocal commentstring=//%s
""""""""""""""""""""""""""""""""""""""""
" 基本設定
""""""""""""""""""""""""""""""""""""""""
" タイトル表示
set title
" Vi互換をオフ
set nocompatible
" 変更中のファイルでも、保存しないで他のファイルを表示
set hidden
" バックアップなし
set nobackup
" スワップファイルなし
set noswapfile
set noundofile
" 自動再読み込み
set autoread
" 行番号を表示する
" set number
" 画面端で折り返さない
set nowrap
" 自動改行をオフにする
set textwidth=0
" ビープ音消す
set noerrorbells
set vb t_vb=
" スペルチェック
set spelllang+=cjk
set spell
" 行間
set lsp=3
" 整形オプション マルチバイト系を追加
set formatoptions=lmoq
" UTF-8の□や○でカーソル位置がずれないようにする
set termencoding=utf-8
set encoding=utf-8
set fileencodings=utf-8,cp932,euc-jp,iso-2022-jp
set ffs=unix,dos,mac
if exists('&ambiwidth')
set ambiwidth=double
endif
" 保存時に行末の空白を除去する(Markdown以外)
autocmd BufWritePre * if &filetype !=? 'markdown' | %s/\s\+$//ge | endif
""""""""""""""""""""""""""""""""""""""""
" インデント
""""""""""""""""""""""""""""""""""""""""
" タブの代わりに空白文字を挿入する
set expandtab
" タブ空白の数
set shiftwidth=4
set softtabstop=4
" 行頭の余白内で Tab を打ち込むと、'shiftwidth' の数だけインデントする。
set smarttab
" オートインデント
set autoindent
" 新しい行を作ったときに高度な自動インデントを行う
set smartindent
" Vim 起動時 vim-indent-guides を自動起動
let g:indent_guides_enable_on_vim_startup=1
" ガイドをスタートするインデントの量
let g:indent_guides_start_level=2
" 自動カラー無効
let g:indent_guides_auto_colors=0
" 奇数番目のインデントの色
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=#444433 ctermbg=black
" 偶数番目のインデントの色
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#333344 ctermbg=darkgray
" ガイドの幅
let g:indent_guides_guide_size = 1
""""""""""""""""""""""""""""""""""""""""
" キーマップ
""""""""""""""""""""""""""""""""""""""""
nnoremap ; :
nnoremap s <Nop>
nnoremap sw :w<CR>
nnoremap sq :q<CR>
nnoremap sn :NERDTreeToggle<CR>
nnoremap st :TagbarToggle<CR>
nnoremap sb :<C-u>Unite buffer file_mru file<CR>
nnoremap sm :<C-u>Unite file_mru<CR>
" TABで補完候補の選択を行う
inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<Up>" : "\<S-TAB>"
" 整形
vnoremap <silent> <Enter> :EasyAlign<CR>
" タスクリスト
nnoremap <F9> :TaskList<CR>
" vを二回で行末まで選択
vnoremap v $h
""""""""""""""""""""""""""""""""""""""""
" タブ操作
""""""""""""""""""""""""""""""""""""""""
" 新規タブ
nmap st :tabe<CR>
nmap s9 :set showtabline=1<CR>
nmap s0 :set showtabline=0<CR>
" タブを移動する
nmap sf :tabnext<CR>
nmap sd :tabNext<CR>
""""""""""""""""""""""""""""""""""""""""
" ウィンドウ操作
""""""""""""""""""""""""""""""""""""""""
" 分割
nnoremap sp :<C-u>sp<CR>
nnoremap sv :<C-u>vs<CR>
" 画面移動
nnoremap ss <C-w>w
nnoremap sr <C-w>r
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap sh <C-w>h
nnoremap sl <C-w>l
nnoremap sgj <C-w>J
nnoremap sgk <C-w>K
nnoremap sgh <C-w>H
nnoremap sgl <C-w>L
" ウィンドウサイズ変更
nnoremap <M-+> <C-w>-
nnoremap <M--> <C-w>+
nnoremap <M-.> <C-w>>
nnoremap <M-,> <C-w><
call submode#enter_with('window-size', 'n', '', 's[', '<C-w>>')
call submode#enter_with('window-size', 'n', '', 's]', '<C-w><')
call submode#enter_with('window-size', 'n', '', 's=', '<C-w>+')
call submode#enter_with('window-size', 'n', '', 's-', '<C-w>-')
call submode#map('window-size', 'n', '', '[', '<C-w>>')
call submode#map('window-size', 'n', '', ']', '<C-w><')
call submode#map('window-size', 'n', '', '=', '<C-w>+')
call submode#map('window-size', 'n', '', '-', '<C-w>-')
""""""""""""""""""""""""""""""""""""""""
" カーソル
""""""""""""""""""""""""""""""""""""""""
" カーソル行の強調表示
set cursorline
" カーソルの上下の余白行
set scrolloff=14
" 選択時の色
highlight Visual ctermbg=17
" モードに応じてカーソルの形状を変える
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
" カーソルを行頭、行末で止まらないようにする
set whichwrap=b,s,h,l,<,>,[,]
" 行内で移動
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" fで先頭に, shift-f押下で行末まで移動
noremap ff ^
noremap F <S-$>
" TABで対応ペアにジャンプ
nnoremap <Tab> %
vnoremap <Tab> %
" カーソル位置をハイライト
"augroup cch
" autocmd! cch
" autocmd WinLeave * set nocursorline
" autocmd WinLeave * set nocursorcolumn
" autocmd WinEnter,BufRead * set cursorline
" autocmd WinEnter,BufRead * set cursorcolumn
"augroup END
" カッコ入力後にカッコ内に移動
" imap {} {}<Left>
" imap [] []<Left>
" imap () ()<Left>
" imap “” “”<Left>
" imap ” ”<Left>
" imap <> <><Left>
" imap “ “<left>
""""""""""""""""""""""""""""""""""""""""
" 検索設定
""""""""""""""""""""""""""""""""""""""""
" 検索ワードにペーストして検索
nmap <F3> :/<C-r>0
" 検索ワードにペーストして置換
nmap <S-F3> :%s/<C-r>0/<C-r>0/gc
" 範囲選択内でペーストして置換
vmap <S-F3> :s/<C-r>0/<C-r>0/gc
" インクリメンタルサーチ
set incsearch
" 検索時に大文字を含んでいたら大/小を区別
set smartcase
" 検索終了後、ファイルの先頭へループしない
" set nowrapscan
" 検索をハイライト
set hlsearch
" ハイライトをESC連打で解除
nmap <Esc><Esc> :nohlsearch<CR><Esc>
"検索パターン入力中は/および?をエスケープ
cnoremap <expr> /
\ getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ?
\ getcmdtype() == '?' ? '\?' : '?'
""""""""""""""""""""""""""""""""""""""""
" 編集設定
""""""""""""""""""""""""""""""""""""""""
" ビジュアルモードになったらIMEオフ
set imdisable
set iminsert=0
set imsearch=-1
" 対応する括弧を表示する
set showmatch
" バックスペースで特殊文字も削除
set backspace=indent,eol,start
" <Enter>で即改行
" noremap <CR> o<ESC>
" \キーでコメントトグルして下の行へ
let NERDSpaceDelims=1
nmap \\ <Plug>NERDCommenterToggle <Down>
vmap \\ <Plug>NERDCommenterToggle <Down>
" 編集時に不可視文字を表示
autocmd InsertEnter * set list
autocmd InsertLeave * set nolist
noremap <C-C> :set nolist<CR>
set listchars=extends:»,eol:$,tab:»-
""""""""""""""""""""""""""""""""""""""""
" コピペ
""""""""""""""""""""""""""""""""""""""""
" クリップボードを利用する
" set clipboard=unnamed
" Paste Mode <F10>
nnoremap <silent> <F10> :call Paste_on_off()<CR>
set pastetoggle=<F10>
" 複数行貼り付け??
" {{{
let paste_mode = 0 " 0 = normal, 1 = paste
function! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
return
endfunc
" }}}
""""""""""""""""""""""""""""""""""""""""
" その他
""""""""""""""""""""""""""""""""""""""""
" 開いてるファイルをサーバ起動してブラウザで開く
noremap <Space>o :!koko -o -p %:h<CR>
" 開いてるファイルをクロームで開く
noremap <Space>c :!open -a "Google Chrome" %<CR>
" 開いてるファイルをMarkedで開く
noremap <Space>m :!open -a "Marked" %<CR>
" 開いてるディレクトリをiTermで開く
noremap <Space>i :!open -a "iTerm" %:h<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment