Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
syntax on
nnoremap ZZ <Nop>
filetype on
filetype indent on
filetype plugin on
set nocompatible
"------------------------------------------------------------------
" view
"------------------------------------------------------------------
set number
set ruler
set wrap
set title
set cursorline
set scrolloff=5
set wildmenu
set laststatus=2
set showcmd
set cmdheight=2
set statusline=%F\ %m%=%{(&fenc!=''?&fenc:&enc).':'.&ff}%{(&list?'>':'')}\ %l-%v\ %p%%\ [%02B]
set foldmethod=manual
"------------------------------------------------------------------
" file
"------------------------------------------------------------------
" 変更中のファイルを保存せずに他のファイルを見れるようにする
set hidden
" 外部のエディタで編集中のファイルが変更されたら、自動的に読み直す
set autoread
"------------------------------------------------------------------
" tab
"------------------------------------------------------------------
set expandtab smarttab
set tabstop=2 softtabstop=2 shiftwidth=2
"------------------------------------------------------------------
" edit
"------------------------------------------------------------------
set autoindent smartindent
set backspace=indent,eol,start
set showmatch
" カレントディレクトリを自動的に変更
set autochdir
" バックスラッシュをスラッシュに置き換え
set shellslash
set list
set listchars=tab:^\ ,trail:~
set iskeyword+=-,!,?
set iskeyword-=_
set indentkeys-=0#"
"------------------------------------------------------------------
" backup
"------------------------------------------------------------------
set nobackup
set noswapfile
"------------------------------------------------------------------
" register
"------------------------------------------------------------------
"set clipboard+=unnamed
set clipboard+=autoselect
"------------------------------------------------------------------
" encoding
"------------------------------------------------------------------
" 内部エンコーディング バッファ・レジスタ
"set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,iso-2022-jp-3,iso-2022-jp-2,euc-jisx0213,euc-jp,cp932
if &encoding == 'utf-8'
set ambiwidth=double
endif
" ただし、下記ファイルタイプのファイルはなにがなんでもutf-8でお願いします><
" autocmd FileType php :set fileencoding=utf-8
autocmd FileType js :set fileencoding=utf-8
autocmd FileType css :set fileencoding=utf-8
autocmd FileType html :set fileencoding=utf-8
autocmd FileType xml :set fileencoding=utf-8
autocmd FileType ruby :set fileencoding=utf-8
autocmd FileType php :set fileencoding=utf-8
"--------------------------------------------------------------------
" key mapping
"--------------------------------------------------------------------
" [Default]
" C-A 数値の加算
" C-X 数値の減産
"
" C-U scrollオプションで指定されている行数だけ上へ移動する
" C-D scrollオプションで指定されている行数だけ下へ移動する
"
" C-B 指定されたページ数だけ上へ移動
" C-F 指定されたページ数だけ下へ移動
"
" C-Y 指定行数上へ移動 カーソルはそのまま
" C-E 指定行数下へ移動 カーソルはそのまま
" C-P 指定された行数だけ上へ移動 kと同じ
" C-N 指定された行数だけ下へ移動 jと同じ
"
" C-H 左に移動 backspaceオプションで挙動を変更できる
" C-J jと同じ
" C-K hと同じ
"
" C-G カレントファイルとそのファイル内のカーソル位置を表示する
" C-R リドゥ
" C-V ヴィジュアルモード
" C-W ウィンドウ
" C-Z サスペンド
" C-I ジャンプリスト? <TAB>と同じ
" C-S ターミナル
" C-Q ターミナル
" C-T タグ?
" C-L ?
" C-C 割り込み検索?
" C-O ?
" C-M <CR>をコピーする
" [再割り当て]
map <C-H> <NUL>
" 必要外
nnoremap <C-H> <Nop>
nnoremap <C-J> <Nop>
nnoremap <C-K> <Nop>
nnoremap <C-G> <Nop>
nnoremap <C-Z> <Nop>
nnoremap <C-I> <Nop>
nnoremap <C-S> <Nop>
nnoremap <C-Q> <Nop>
nnoremap <C-T> <Nop>
nnoremap <C-L> <Nop>
nnoremap <C-C> <Nop>
nnoremap <C-O> <Nop>
nnoremap <C-M> <Nop>
" cursor
nnoremap j gj
nnoremap k gk
nnoremap w 4l
"nnoremap <C-J> L4j
"nnoremap <C-K> H4k
nnoremap <C-J> 4<C-E> 4j
nnoremap <C-K> 4<C-Y> 4k
nnoremap z 0
nnoremap . $
" shortcut
nnoremap <CR> <CR>
nnoremap <silent> <C-U> :call SmoothScroll("d",1, 1)<CR>
nnoremap <silent> <C-I> :call SmoothScroll("u",1, 1)<CR>
" NERDTree
nnoremap <silent><C-e> :NERDTreeToggle<CR>
"------------------
" Visual mode
"------------------
vnoremap v $h
vnoremap a <Esc>ggvG
vnoremap <C-j> 4j
vnoremap <C-k> 4k
"------------------
" shortcut
"-----------------
" help
nnoremap ;h <ESC>:help
" hatena diary
nnoremap <space>h :HatenaEdit<CR>
" save
nnoremap ;w <ESC>:w<CR>
inoremap ;w <ESC>:w<CR>
" quit
" noremap ;q <ESC>:q!<CR>
" edit and reflection vimrc
nnoremap <Space>. :<C-u>edit $MYVIMRC<CR>
nnoremap <Space>s. :<C-u>source $MYVIMRC<CR>
nnoremap <Space>z. :<C-u>edit $HOME/.zshrc<CR>
nnoremap <Space>sz. :<C-u>!source $HOME/.zshrc<CR>
" buffer control
" 使わないなこれ
"nnoremap <C-P> <ESC>:bp<CR>
"nnoremap <C-N> <ESC>:bn<CR>
nnoremap <C-D> <ESC>:bdelete<CR>
"window control
nnoremap <C-C> <ESC>:close<CR>
nnoremap ;s <ESC>:split<CR>
nnoremap ;v <ESC>:vsplit<CR>
" Quick Fix
nnoremap q <Nop>
nnoremap qo :copen<CR>
nnoremap qc :cclose<CR>
highlight Folded ctermfg=2 ctermbg=8
vnoremap zz :fold<CR>
vnoremap zo :foldopen!<CR>
" copy and paste
"vmap <C-C> "+y
"imap <C-V> <ESC>"*pa
">vm>ap <C-V> d"*P
"cmap <C-V> <C-R>*
"vmap <C-X> "*d<ESC>
"------------------
" insert mode
"------------------
inoremap <ESC> <ESC>l
inoremap <C-S> <Nop>
inoremap <C-J> <DOWN>
inoremap <C-K> <UP>
inoremap <C-L> <RIGHT>
inoremap <C-h> <LEFT>
inoremap <C-D> <ESC>xa
inoremap ;d <ESC>Da
inoremap ;a <ESC>A
inoremap ;b <ESC>d0i
"time stamp
inoremap ;t <C-R>=strftime("(%H:%M)", localtime())<CR>
" ruby arrow
inoremap ;> =>
inoremap ;< <%= %>
" php begin
inoremap ;? <?php ?>
inoremap ;do do<CR>end<ESC>O
"--------------------------------------------------------------------------
" neobundle
"------------------------------------------------------------------
set nocompatible " Be iMproved
filetype off " Required!
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundle 'Shougo/neobundle.vim'
" 全般
NeoBundle 'https://github.com/Shougo/unite.vim.git'
" git
NeoBundle 'tpope/vim-fugitive'
" color
NeoBundle 'w0ng/vim-hybrid'
" リファレンス
"NeoBundle 'https://github.com/thinca/vim-ref.git'
" 編集履歴管理
"NeoBundle 'sjl/gundo.vim'
" 見た目
"NeoBundle 'https://github.com/Lokaltog/vim-powerline.git'
" shell
"NeoBundle 'Shougo/vimshell'
" filer
"NeoBundle 'Shougo/vimfiler'
NeoBundle 'LustyExplorer'
" asynchronous
"NeoBundle 'Shougo/vimproc'
" vinary
"NeoBundle 'https://github.com/Shougo/vinarise.git'
"
NeoBundle 'matchit.zip'
"emmet記法
NeoBundle 'mattn/emmet-vim'
"NERDTree
NeoBundle 'scrooloose/nerdtree'
"slim syntax
NeoBundle 'slim-template/vim-slim'
"coffee syntax
NeoBundle 'kchmck/vim-coffee-script'
call neobundle#end()
filetype plugin indent on " Required!
""""""""""""""""""""""""""""""
" rails vim
"""""""""""""""""""""""""""""
nnoremap ;rr :R<CR>
nnoremap ;rc :Rcontroller
nnoremap ;rv :Rview
nnoremap ;rm :Rmodel
nnoremap ;rl :Rlayout
nnoremap ;rd :Rmigration
nnoremap ;rs :Rstylesheet
nnoremap ;rj :Rjavascript
""""""""""""""""""""""""""""""
" grep vim
"""""""""""""""""""""""""""""
nnoremap <silent> ;g :GrepBuffer<CR>
nnoremap <silent> <C-G> :Grep<CR>
let Grep_Find_Path = '/home/snoky/work/rails_app/'
nnoremap <silent> ;l :HyperExplorer<CR>
""""""""""""""""""""""""""""""
" Lusty Explorer
"""""""""""""""""""""""""""""
nnoremap <silent> <C-L> :LustyBufferExplorer<CR>
nnoremap <silent> <C-O> :LustyFilesystemExplorer<CR>
"""""""""""""""""""""""""""""
" autocomplpop.vim
""""""""""""""""""""""""""""""
" ポップアップメニューのカラーを設定
highlight Pmenu ctermbg=4
highlight PmenuSel ctermbg=1
highlight PMenuSbar ctermbg=6
" ON/OFF
inoremap <expr> ;c
\ (exists('#AcpGlobalAutoCommand#InsertEnter')) ? "\<C-o>:AcpDisable\<CR>" : "\<C-o>:AcpEnable\<CR>"
" 辞書設定
" 初期値 ".,w,b,u,t,i" (.)カレントバッファ (w,u,t)別バッファ (i)インクルード? (k)dictionary
autocmd Filetype * let g:acp_completeOption='.,w,b,u,t,i'
autocmd Filetype ruby let g:acp_completeOption='.,w,b,u,t,i,k~/.vim/dict/ruby.dict'
"<TAB>で補完
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<TAB>"
else
if pumvisible()
return "\<C-N>"
else
return "\<C-N>\<C-P>"
end
endif
endfunction
" Remap the tab key to select action with InsertTabWrapper
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
" ENTERですぐにポップアップを消す
inoremap <expr> <CR> pumvisible() ? "\<C-Y>\<CR>" : "\<CR>"
" ENTERで補完しない autoload/autocomplpop.vimrcEx
"return "\<C-P>\<DOWN>" -> "\<C-P>"
""""""""""""""""""""""""""""""
" surround.vim for HTML
""""""""""""""""""""""""""""""
" insert mode <C-G> s hoge
" [key map]
" 1 : <h1>|</h1>
" 2 : <h2>|</h2>
" 3 : <h3>|</h3>
" 4 : <h4>|</h4>
" 5 : <h5>|</h5>
" 6 : <h6>|</h6>
"
" p : <p>|</p>
" u : <ul>|</ul>
" o : <ol>|</ol>
" l : <li>|</li>
" a : <a href="">|</a>
" A : <a href="|"></a>
" i : <img src="|" alt="" />
" I : <img src="" alt"|" />
" d : <div>|</div>
" D : <div class="section">|</div>
" s :
" S : <script type="text/javascript">|</script>
autocmd FileType html,eruby,php let b:surround_49 = "<h1>\r</h1>"
autocmd FileType html,eruby,php let b:surround_50 = "<h2>\r</h2>"
autocmd FileType html,eruby,php let b:surround_51 = "<h3>\r</h3>"
autocmd FileType html,eruby,php let b:surround_52 = "<h4>\r</h4>"
autocmd FileType html,eruby,php let b:surround_53 = "<h5>\r</h5>"
autocmd FileType html,eruby,php let b:surround_54 = "<h6>\r</h6>"
autocmd FileType html,eruby,php let b:surround_112 = "<p>\r</p>"
autocmd FileType html,eruby,php let b:surround_117 = "<ul>\r</ul>"
autocmd FileType html,eruby,php let b:surround_111 = "<ol>\r</ol>"
autocmd FileType html,eruby,php let b:surround_108 = "<li>\r</li>"
autocmd FileType html,eruby,php let b:surround_97 = "<a href=\"\">\r</a>"
autocmd FileType html,eruby,php let b:surround_65 = "<a href=\"\r\"></a>"
autocmd FileType html,eruby,php let b:surround_105 = "<img src=\"\r\" alt=\"\" />"
autocmd FileType html,eruby,php let b:surround_73 = "<input \rtype=\"\" name=\"\" value=\"\" />"
autocmd FileType html,eruby,php let b:surround_100 = "<div>\r</div>"
autocmd FileType html,eruby,php let b:surround_68 = "<div \rid=\"\" class=\"\"></div>"
autocmd FileType html,eruby,php let b:surround_83 = "<script type=\"text\/javascript\">\r</script>"
autocmd FileType html,eruby,php let b:surround_115 = "<style type=\"text\/css\">\r</style>"
""""""""""""""""""""""""""""""
" yankring.vim
""""""""""""""""""""""""""""""
"let g:yankring_n_keys = 'Y D'
"let g:yankring_replace_n_nkey = '<C-:>'
"let g:yankring_replace_n_pkey = ';p'
""""""""""""""""""""""""""""""
" yanktmpr.vim
""""""""""""""""""""""""""""""
vnoremap <silent> sy :call YanktmpYank()<CR>
nnoremap <silent> sp :call YanktmpPaste_p()<CR>
nnoremap <silent> sP :call YanktmpPaste_P()<CR>
""""""""""""""""""""""""""""""
" NERD COMMENTER
""""""""""""""""""""""""""""""
"nmap ;cc <plug>NERDCommenterComment
"vmap ;cc <plug>NERDCommenterComment
nmap ;c <plug>NERDCommenterToggle
vmap ;c <plug>NERDCommenterToggle
nmap ;d <Nop>
vmap ;d <Nop>
"------------------------------------------------------------------
" templates
"------------------------------------------------------------------
autocmd BufNewFile *.html 0r ~/.vim/templates/skel.html
autocmd BufNewFile *.rb 0r ~/.vim/templates/skel.rb
"------------------------------------------------------------------
" functions
"------------------------------------------------------------------
""""""""""""""""""""""""""""""
"挿入モード時、ステータスラインの色を変更
""""""""""""""""""""""""""""""
if has('syntax')
syntax on
augroup InsertHook
autocmd!
autocmd InsertEnter * highlight StatusLine guifg=darkblue guibg=darkyellow gui=none ctermfg=black ctermbg=green cterm=none
autocmd InsertLeave * highlight StatusLine guifg=darkblue guibg=darkgrey gui=none ctermfg=black ctermbg=grey cterm=none
augroup END
endif
""""""""""""""""""""""""""""""
"ファイルを開いたら前回のカーソル位置へ移動
""""""""""""""""""""""""""""""
augroup vimrcEx
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line('$') |
\ exe "normal! g`\"" |
\ endif
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment