Skip to content

Instantly share code, notes, and snippets.

@yassu
Created December 11, 2016 06:59
Show Gist options
  • Save yassu/c5b84c87879888e27af47cd545f09c00 to your computer and use it in GitHub Desktop.
Save yassu/c5b84c87879888e27af47cd545f09c00 to your computer and use it in GitHub Desktop.
my vimrc
scriptencoding utf-8
set encoding=utf-8
set fileencodings=utf-8,euc-jp,iso-2022-jp,sjis
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
call dein#begin(expand('~/.vim/dein/'))
call dein#add('thinca/vim-quickrun')
autocmd BufRead,BufNewFile *_test.py set filetype=python.test
let g:quickrun_config = {}
let g:quickrun_config['python.test'] = {
\'command': 'nosetests',
\'hook/shebang/enable': 0,
\}
let g:quickrun_config['markdown'] = {
\'command': 'shiba',
\'cmdopt': '--detach',
\'hook/shebang/enable': 0,
\}
let g:quickrun_config['yaml'] = {
\'command': 'yamllint',
\'hook/shebang/enable': 0,
\}
call dein#add('Shougo/unite.vim')
call dein#add('yegappan/mru')
call dein#add('kana/vim-textobj-indent')
call dein#add('junegunn/vim-easy-align')
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
call dein#add('tpope/vim-surround')
let g:surround_{char2nr('@')} = "```\n\r\n```````\n"
let g:surround_{char2nr('7')} = "'''\n\r\n'''''''\n"
let g:surround_{char2nr('2')} = "\"\"\"\n\r\n\"\"\""
let g:surround_{char2nr('4')} = "$\r$"
call dein#add('kana/vim-textobj-user')
call dein#add('kana/vim-textobj-entire')
call dein#add('woowee/memolist.vim')
let g:memolist_qfixgrep = 0
let g:memolist_path = '~/.vim/memo'
command! MGrep MemoGrep
command! MNew MemoNew
command! MList MemoList
set conceallevel=0
call dein#add('tomtom/tcomment_vim')
call dein#add('koron/codic-vim')
call dein#add('bronson/vim-trailing-whitespace')
call dein#add('thinca/vim-showtime')
call dein#add('jnurmine/Zenburn')
call dein#add('motemen/git-vim')
let g:git_no_map_default = 1
command! G Git
command! GAdd GitAdd
command! GCom GitCommit
command! GSta GitStatus
command! GLog GitLog
command! GCout GitCheckout
command! GDiff GitDiff
command! GPull GitPull
command! GPullRebase GitPullRebase
command! GPush GitPush
command! GCatFile GitCatFile
command! GVimDiffMerge GitVimDiffMerge
command! GVimDiffMergeDone GitVimDiffMergeDone
call dein#add('danro/rename.vim')
call dein#add('ujihisa/repl.vim')
call dein#add('soramugi/auto-ctags.vim')
let g:auto_ctags = 1
call dein#add('vim-jp/vimdoc-ja')
call dein#add('harleypig/vcscommand.vim')
command! VAdd VCSAdd
command! VAnnotate VCSAnnotate
command! VBlame VCSBlame
command! VCommit VCSCommit
command! VCom VCSCommit
command! VDelete VCSDelete
command! VDiff VCSDiff
command! VGotoOriginal VCSGotoOriginal
command! VLog VCSLog
command! VRemove VCSRemove
command! VRevert VCSRevert
command! VReview VCSReview
command! VStatus VCSStatus
command! VSta VCSStatus
command! VUpdate VCSUpdate
command! VVimDiff VCSVimDiff
call dein#add('scrooloose/nerdtree')
nnoremap \n :NERDTreeToggle<cr>
augroup Setting-Nerdtree
autocmd!
autocmd! FileType nerdtree nnoremap <buffer> <leader>o :Bookmark<cr>
augroup END
call dein#add('lambdalisue/vim-gista')
let g:gista#github_user = 'yassu'
call dein#add('kana/vim-textobj-underscore')
call dein#add('thinca/vim-template')
call dein#add('rust-lang/rust.vim')
call dein#end()
" colorscheme zellner
colorscheme zenburn
set background=dark
""" filetype {{{
autocmd BufWinEnter,BufNewFile SConstruct set filetype=python
autocmd BufWinEnter,BufNewFile *test*.py set filetype=python.test
autocmd BufNewFile,BufRead *.tex setfiletype tex
autocmd BufNewFile,BufRead *.go setfiletype go
autocmd BufNewFile,BufRead *.sage setfiletype python
autocmd BufNewFile,BufRead *.markdown setfiletype markdown
autocmd BufNewFile,BufRead *.plant setfiletype plantuml
autocmd BufNewFile,BufRead *.puml setfiletype plantuml
autocmd BufNewFile,BufRead *.iuml setfiletype plantuml
autocmd BufNewFile,BufRead *.diag setfiletype blockdiag
autocmd BufNewFile,BufRead *.max setfiletype maxima
autocmd BufNewFile,BufRead *.gnu setfiletype gnuplot
autocmd BufNewFile,BufRead *.md setfiletype markdown
autocmd BufNewFile,BufRead *.mkd setfiletype markdown
""" }}}
""" tex {{{
let tex_conceal = ''
""" }}}
""" json {{{
augroup Setting-Json
autocmd!
autocmd FileType json setlocal conceallevel=0
augroup END
""" }}}
""" system {{{
set nonumber
set visualbell t_vb=
set noequalalways
" set clipboard+=autoselect
" set clipboard+=unnamed
set ignorecase
set scrolloff=3
set wildmode=list:longest
set laststatus=2
set statusline=%F%m%r%h%w\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%]
set incsearch
set foldmethod=marker
autocmd FileType tex set foldcolumn=2
autocmd FileType vim set foldcolumn=2
if exists('&ambiwidth')
set ambiwidth=double
endif
set list listchars=tab:>>,trail:.
set undofile
set undodir=~/.vim/undo
set backupdir=~/.vim/backup
set directory=~/.vim/swp
":uuuabcabc
" defdef
set expandtab
"" 一行80文字{{{
setlocal colorcolumn=80
setlocal textwidth=80
set tabstop=2
set softtabstop=2
set shiftwidth=2
"" tex {{{
augroup Setting-Yaml
autocmd!
autocmd FileType tex setlocal colorcolumn=100
autocmd FileType tex setlocal textwidth=100
autocmd FileType tex setlocal tabstop=2
autocmd FileType tex setlocal softtabstop=2
autocmd FileType tex setlocal shiftwidth=2
augroup END
"" }}}
"" html {{{
augroup Setting-Yaml
autocmd!
autocmd FileType html setlocal textwidth=100
autocmd FileType html setlocal tabstop=2
autocmd FileType html setlocal softtabstop=2
autocmd FileType html setlocal shiftwidth=2
augroup END
"" }}}
"" yaml {{{
augroup Setting-Yaml
autocmd!
autocmd FileType yaml setlocal textwidth=100
autocmd FileType yaml setlocal softtabstop=2
autocmd FileType yaml setlocal shiftwidth=2
augroup END
"" }}}
"" plant {{{
augroup Setting-PlantUML
autocmd!
autocmd FileType plant setlocal textwidth=100
autocmd FileType plant setlocal tabstop=2
autocmd FileType plant setlocal softtabstop=2
autocmd FileType plant setlocal shiftwidth=2
augroup END
" }}}
"" python {{{
augroup Setting-Python
autocmd!
autocmd FileType python setlocal textwidth=80
autocmd FileType python setlocal tabstop=4
autocmd FileType python setlocal softtabstop=4
autocmd FileType python setlocal shiftwidth=4
autocmd FileType python setlocal colorcolumn=80
augroup END
"" }}}
"" ruby {{{
augroup Setting-Ruby
autocmd!
autocmd FileType ruby setlocal colorcolumn=80
autocmd FileType ruby setlocal textwidth=80
autocmd FileType ruby setlocal tabstop=2
autocmd FileType ruby setlocal softtabstop=2
autocmd FileType ruby setlocal shiftwidth=2
augroup END
"" }}}
"" hs {{{
augroup Setting-Haskell
autocmd!
autocmd FileType haskell setlocal colorcolumn=80
autocmd FileType haskell setlocal textwidth=80
autocmd FileType haskell setlocal tabstop=2
autocmd FileType haskell setlocal softtabstop=2
autocmd FileType haskell setlocal shiftwidth=2
augroup END
"" }}}
"" blockdiag {{{
augroup Setting-Blockdiag
autocmd!
autocmd FileType diag setlocal colorcolumn=80
autocmd FileType diag setlocal textwidth=80
autocmd FileType diag setlocal tabstop=2
autocmd FileType diag setlocal softtabstop=2
autocmd FileType diag setlocal shiftwidth=2
augroup END
"" }}}
"" tex {{{
augroup Setting-Tex
autocmd!
autocmd FileType tex setlocal colorcolumn=80
autocmd FileType tex setlocal textwidth=80
autocmd FileType tex setlocal tabstop=4
autocmd FileType tex setlocal softtabstop=4
autocmd FileType tex setlocal shiftwidth=4
augroup END
"" }}}
"" maxima {{{
augroup Setting-Maxima
autocmd!
autocmd FileType maxima setlocal colorcolumn=100
autocmd FileType maxima setlocal textwidth=100
autocmd FileType maxima setlocal tabstop=2
autocmd FileType maxima setlocal softtabstop=2
autocmd FileType maxima setlocal shiftwidth=2
augroup END
""}}}
""" }}}
""}}}
""" commands {{{
command! Fab !fab view
command! Dog !shiba --detach %
command! TT :e ~/tasks.markdown
""" }}}
"" 終了するときにファイル情報を保存する {{{
autocmd BufWinLeave *? silent mkview
autocmd BufWinEnter *? silent loadview
"" }}}
" すべての数値を10進数と考える" {{{
set nrformats =
" }}}
"" 賢いインデント {{{
set autoindent
set smartindent
"" }}}
" Jでカーソル位置を変更しない {{{
nnoremap J mzJ`z:delm z<cr>
" }}}
" wildignore{{{
set wildignore=*.o,*.obj,*~,*.pyc
set wildignore+=.git
set wildignore+=.tmp
set wildignore+=.coverage
set wildignore+=__pycache__/
set wildignore+=*.egg,*.egg-info
set wildignore+=*.png,*.jpg,*.gif
set wildignore+=*.pdf
"}}}
"" setting of tab{{{
" Anywhere SID.
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$')
endfunction
" Set tabline.
function! s:my_tabline()
let s = ''
for i in range(1, tabpagenr('$'))
let bufnrs = tabpagebuflist(i)
let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
let no = i " display 0-origin tabpagenr.
let mod = getbufvar(bufnr, '&modified') ? '!' : ' '
let title = fnamemodify(bufname(bufnr), ':t')
let title = '[' . title . ']'
let s .= '%'.i.'T'
let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
let s .= no . ':' . title
let s .= mod
let s .= '%#TabLineFill# '
endfor
let s .= '%#TabLineFill#%T%=%#TabLine#'
return s
endfunction
let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()'
set showtabline=2 " 常にタブラインを表示
" The prefix key.
nnoremap [Tag] <Nop>
nmap T [Tag]
" Tab jump
for s:n in range(1, 9)
execute 'nnoremap <silent> [Tag]'.s:n ':<C-u>tabnext'.s:n.'<CR>'
endfor
" t1 で1番左のタブ、t2 で1番左から2番目のタブにジャンプ
map <silent> [Tag]c :tablast <bar> tabnew<CR>
" tc 新しいタブを一番右に作る
map <silent> [Tag]x :tabclose<CR>
" tx タブを閉じる
map <silent> [Tag]n :tabnext<CR>
" tn 次のタブ
map <silent> [Tag]p :tabprevious<CR>
" tp 前のタブ
"" }}}
""" load vimrc of local {{{
augroup vimrc-local
autocmd!
autocmd BufNewFile,BufReadPost * call s:vimrc_local(expand('<afile>:p:h'))
augroup END
function! s:vimrc_local(loc)
let files = findfile('.lcvimrc', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
endfor
endfunction
""" }}}
"" 下線を引く {{{
function! s:drawUnderLine(...)
let l:sep = get(a:, 1, '-')
call append('.', repeat(l:sep, len(getline('.')) + 2))
endfunction
command! -nargs=? UnderLine call s:drawUnderLine(<f-args>)
nnoremap <leader>u :UnderLine<cr>
nnoremap <leader>U :UnderLine<space>
"" }}}
""" task-list {{{
let g:task_filename=expand('~/.vim/memo/tasks')
nmap <Space>t :e <c-r>=g:task_filename<cr><cr>
""" }}}
" mapping {{{
"" move by paragraph {{{
nnoremap <RIGHT> <NOP>
nnoremap <LEFT> <NOP>
nnoremap <UP> <NOP>
nnoremap <DOWN> <NOP>
nnoremap L :cnext<cr>
nnoremap H :cprev<cr>
"" }}}
"" vimrc {{
nnoremap <leader>. :e ~/dotfiles/vimrc<cr>
nnoremap <Leader>? :source ~/dotfiles/vimrc<cr>
nnoremap <c-n> <c-a><c-x>
"" }}
""" <c-c>で次の行に移動してnormalmodeに {{{
nnoremap <Space>h :<c-u>help<Space>
nnoremap <silent><c-c> o<esc>
nnoremap <space>w :write<cr>
""" }}}
""" 文字削除のmap {{{
nnoremap <silent>c_ ct_
nnoremap <silent>d_ dt_
nnoremap <silent>c) ct)
nnoremap <silent>d) dt)
nnoremap <silent>c} ct}
nnoremap <silent>d} dt}
nnoremap <silent>c] ct]
nnoremap <silent>d] dt]
nnoremap <silent>d' dt'
nnoremap <silent>c' ct'
nnoremap <silent>d" dt"
nnoremap <silent>c" ct"
nnoremap <silent>d. dt.
nnoremap <silent>c. ct.
nnoremap <silent>d\ d$
nnoremap <silent>D ^d$
nnoremap <silent>c$ d$a
nnoremap <silent>c\ c$
""" }}}
nmap <leader>s :set number!<cr>
nmap <leader>l :set list!<cr>
nmap <space>z :on<cr>
" }}}
syntax on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment