Skip to content

Instantly share code, notes, and snippets.

@m-note
Last active February 28, 2016 01:35
Show Gist options
  • Save m-note/72ae7d7defc410f293d8 to your computer and use it in GitHub Desktop.
Save m-note/72ae7d7defc410f293d8 to your computer and use it in GitHub Desktop.
Vimの設定ファイル
set nocompatible
nnoremap O :<C-u>call append(expand('.'), '')<Cr>j
"行番号を表示する
set number
"タブ幅の設定、Tabではなくスペース4つにする
set tabstop=2
set noexpandtab
set shiftwidth=2
set softtabstop=0
"新しい行のインデントを現在行と同じにする
set autoindent
set smartindent
"バックアップをとらない
set nobackup
"ビープ音を出さない
set visualbell t_vb=
"括弧ハイライトの調整 cf. http://goo.gl/acS2xh http://goo.gl/4caCgN
autocmd ColorScheme * highlight MatchParen gui=bold,underline guibg=white guifg=orange
"勝手に括弧のハイライトでカーソルを動かさない
set noshowmatch
"括弧の補完
inoremap { {}<Left>
inoremap [ []<Left>
inoremap ( ()<Left>
inoremap {<Enter> {}<Left><CR><ESC><S-o>
inoremap [<Enter> []<Left><CR><ESC><S-o>
inoremap (<Enter> ()<Left><CR><ESC><S-o>
"ビジュアルモードでは勝手にヤンクしないようにする cf. http://goo.gl/7jq1Th
vnoremap d "_d
noremap D "_D
"noremap p "0p
"Undoの情報はセッションを超えて保存しない
:set noundofile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"NeoBundel用
" Note: Skip initialization for vim-tiny or vim-small.
if 0 | endif
filetype off
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved
endif
set runtimepath+=~/.vim/bundle/neobundle.vim
endif
call neobundle#begin(expand('~/.vim/bundle/'))
" 以下にあるものが追加されるみたい
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
"NeoBundle 'VimClojure'
"NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/unite.vim'
"NeoBundle 'Shougo/neocomplcache'
"NeoBundle 'jpalardy/vim-slime'
"NeoBundle 'scrooloose/syntastic'
"NeoBundle 'Shougo/vimfiler.vim'
"NeoBundle 'itchyny/lightline.vim'
"NeoBundle 't9md/vim-textmanip'
NeoBundle 'Shougo/unite.vim'
"NeoBundle 'ujihisa/unite-colorscheme'
"NeoBundle 'tomasr/molokai'
""NeoBundle 'https://bitbucket.org/kovisoft/slimv'
call neobundle#end()
filetype plugin indent on " required!
filetype indent on
syntax on
NeoBundleCheck
"""""""""""""""""""""""""""""""""""""""""
"以下はLaTexの変換用
" for LaTeX
NeoBundle 'lervag/vimtex'
let g:vimtex_fold_envs = 0
" vim-quickrun
"let g:quickrun_config = {}
let g:quickrun_config = {
\ "_" : {
\ "runner" : "vimproc",
\ "runner/vimproc/updatetime" : 60
\ },
\}
NeoBundle 'thinca/vim-quickrun'
"QuickRunでコンパイル中、<C-c> で実行を強制終了させる
"quickrun.vim が実行していない場合には <C-c> を呼び出す
nnoremap <expr><silent> <C-c> quickrun#is_running() ? quickrun#sweep_sessions() : "\<C-c>"
" disable the conceal function
let g:tex_conceal=''
"""""""""""""""""""""""""""""""""""""""""
"プログラムのコンパイル
"F5でCのコンパイル cf. http://goo.gl/MBWvoM
"実行コマンド
command! Run1 call s:Run1()
nmap <F5> :Run1<CR>
function! s:Run1()
let e = expand("%:e")
if e == "c"
:Gcc1
endif
if e == "py"
:Python31
endif
if e == "cpp"
:CPP1
endif
"if e == "tex" "大学ではこのifが必要だった
" :QuickRun
"endif
endfunction
command! Gcc1 call s:Gcc1()
function! s:Gcc1()
if has("win32") || has("win64")
:!gcc % -o %:r.exe
:!%:r.exe
else
:!sudo gcc % -o %:r.out
:!%:p:h/%:r.out
":!./%:r.out "at Uni
endif
endfunction
command! Python31 call s:Python1()
function! s:Python1()
:!python3 %
endfunction
command! CPP1 call s:CPP1()
function! s:CPP1()
:!sudo c++ % -o %:r.out
:!%:p:h/%:r.out
":!./%:r.out "at Uni
endfunction
"QuickRunで実行
command! Run call s:Run()
nmap <F6> :Run<CR>
function! s:Run()
let e = expand("%:e")
if e == "c"
:Gcc
endif
if e == "py"
:Python3
endif
if e == "cpp"
:CPP
endif
endfunction
command! Gcc call s:Gcc()
function! s:Gcc()
if has("win32") || has("win64")
:!gcc % -o %:r.exe
:!%:r.exe
else
:QuickRun c -hook/time/enable 1
endif
endfunction
command! Python3 call s:Python()
function! s:Python()
:QuickRun python3
endfunction
command! CPP call s:CPP()
function! s:CPP()
:QuickRun cpp
endfunction
"""""""""""""""""""""""""""""""""""""""""
" ~/.vim/ftplugin/tex_quickrun.vim に保存。なければフォルダを自分で作る。 / Texのコンパイルに必要
" 指定した範囲でF5をすると、tmptex.pdfというファイルができ、そこにプレビューされる。
" どこも指定せずにF5をすると、そのファイル全体がコンパイルされる。
"http://qiita.com/ssh0/items/4aea2d3849667717b36dを参考にした。自分の保存用。
" LaTeX Quickrun
let g:quickrun_config['tex'] = {
\ 'command' : 'latexmk',
\ 'outputter' : 'error',
\ 'outputter/error/success' : 'null',
\ 'outputter/error/error' : 'quickfix',
\ 'srcfile' : expand("%"),
\ 'cmdopt': '-pdfdvi',
\ 'hook/sweep/files' : [
\ '%S:p:r.aux',
\ '%S:p:r.bbl',
\ '%S:p:r.blg',
\ '%S:p:r.dvi',
\ '%S:p:r.fdb_latexmk',
\ '%S:p:r.fls',
\ '%S:p:r.log',
\ '%S:p:r.out'
\ ],
\ 'exec': '%c %o %a %s',
\}
" 部分的に選択してコンパイル
" http://auewe.hatenablog.com/entry/2013/12/25/033416 を参考に
let g:quickrun_config.tmptex = {
\ 'exec': [
\ 'mv %s %a/tmptex.latex',
\ 'latexmk -pdfdvi -pv -output-directory=%a %a/tmptex.latex',
\ ],
\ 'args' : expand("%:p:h:gs?\\\\?/?"),
\ 'outputter' : 'error',
\ 'outputter/error/error' : 'quickfix',
\
\ 'hook/eval/enable' : 1,
\ 'hook/eval/cd' : "%s:r",
\
\ 'hook/eval/template' : '\documentclass{jsarticle}'
\ .'\usepackage[dvipdfmx]{graphicx, hyperref}'
\ .'\usepackage{float}'
\ .'\usepackage{amsmath,amssymb,amsthm,ascmac,mathrsfs}'
\ .'\allowdisplaybreaks[1]'
\ .'\theoremstyle{definition}'
\ .'\newtheorem{theorem}{定理}'
\ .'\newtheorem*{theorem*}{定理}'
\ .'\newtheorem{definition}[theorem]{定義}'
\ .'\newtheorem*{definition*}{定義}'
\ .'\renewcommand\vector[1]{\mbox{\boldmath{\$#1\$}}}'
\ .'\begin{document}'
\ .'%s'
\ .'\end{document}',
\
\ 'hook/sweep/files' : [
\ '%a/tmptex.latex',
\ '%a/tmptex.out',
\ '%a/tmptex.fdb_latexmk',
\ '%a/tmptex.log',
\ '%a/tmptex.aux',
\ '%a/tmptex.dvi'
\ ],
\}
"vnoremap <silent><buffer> <F4> :QuickRun -mode v -type tmptex<CR>
vnoremap <silent><buffer> <F5> :QuickRun -mode v -type tmptex<CR>
" QuickRun and view compile result quickly (but don't preview pdf file)
"nnoremap <silent><F4> :QuickRun<CR>
nnoremap <silent><F5> :QuickRun<CR>
" 自動で生成したい場合
"autocmd BufWritePost,FileWritePost *.tex QuickRun tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment