Skip to content

Instantly share code, notes, and snippets.

@shishi
Created September 1, 2012 05:05
Show Gist options
  • Save shishi/3564231 to your computer and use it in GitHub Desktop.
Save shishi/3564231 to your computer and use it in GitHub Desktop.
vimrc
set encoding=utf-8
set fileencodings=utf-8,cp932,euc-jp,iso-2022-jp-3,euc-jisx0213,guess,ucs-bom,ucs-2le,ucs-2
"オリジナルの順はguess, ucs-bom, ucs-2le,ucs-2, iso-2022-jp-3,utf-8, euc-jisx0213, euc-jp
scriptencoding utf-8
"autocmd初期化
augroup MyAutoCmd
autocmd!
augroup END
"オプション--------------------------------------------------------------------------
syntax on
filetype plugin on
set autoindent
set nobackup
set backspace=indent,eol,start
set browsedir=buffer
set cindent
set clipboard+=unnamed
set cmdheight=2
set expandtab
set hidden
set history=100
set ignorecase
set incsearch
set laststatus=2
set list
set listchars=tab:>-,extends:>,trail:-,eol:<
set matchpairs=(:),{:},[:],<:>
set modeline
set nocompatible
set number
set ruler
set shiftwidth=4
set showcmd
set showmatch
set smartcase
set smarttab
set tabstop=4
set wildmenu
set wrap
set wrapscan
set writebackup
set showfulltag
set visualbell t_vb="
set hid
"色、可視化--------------------------------------------------------------------------
"全角スペース可視化
augroup highlightIdegraphicSpace
autocmd!
autocmd Colorscheme * highlight IdeographicSpace term=underline ctermbg=DarkGreen guibg=DarkGreen
autocmd VimEnter,WinEnter * match IdeographicSpace / /
augroup END
"ステータスラインに表示する情報の指定
set statusline=%n\:%y%F\ \|%{(&fenc!=''?&fenc:&enc).'\|'.&ff.'\|'}%m%r%=<%l/%L:%p%%>
"入力モード時、ステータスラインのカラーを変更
augroup InsertHook
autocmd!
autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
augroup END
"カラースキーム
colorscheme desert
"TOhtml
let g:use_xhtml = 1
let g:html_use_css = 1
let g:html_no_pre = 1
"map---------------------------------------------------------------------------------
"ev,egで.vimrc,.gvimrcを編集
nnoremap <silent> <Space>ev :<C-u>edit $MYVIMRC<CR>
nnoremap <silent> <Space>eg :<C-u>edit $MYGVIMRC<CR>
"Load .gvimrc after .vimrc edited at GVim.
nnoremap <silent> <Space>rv :<C-u>source $MYVIMRC \| if has('gui_running') \| source $MYGVIMRC \| endif <CR>
nnoremap <silent> <Space>rg :<C-u>source $MYGVIMRC<CR>
"CTRL+hで:help
nnoremap <C-h> :<C-u>help<Space>
"CTRL+shift+hで:helpgrep
nnoremap <M-h> :<C-u>helpgrep<Space>
"マーク位置へのジャンプを行だけでなく桁位置も復元できるようにする
map ' `
"ALT+nで次のバッファを表示
map <M-n> :bnext<CR>
"ALT+pで前のバッファを表示
map <M-p> :bprevious<CR>
"挿入モードでCTRL+kを押すとクリップボードの内容を貼り付けられるようにする
imap <C-k> <ESC>p*a
"ノーマルモードCTRL+sで検索+ペースト、コマンドモードALT+sでクリップボードの内容をペースト
nnoremap <C-s> /<C-r>+
cnoremap <M-s> <C-r>+
"インサートモード時にALTで移動"
inoremap <M-h> <Left>
inoremap <M-j> <Down>
inoremap <M-k> <Up>
inoremap <M-l> <Right>
"ALTで上下左右に表示しているウィンドウをスクロールさせる
"nnoremap <M-h> <C-W>h<C-E><C-W><C-W>
"nnoremap <M-j> <C-W>j<C-E><C-W><C-W>
"nnoremap <M-k> <C-W>k<C-E><C-W><C-W>
"nnoremap <M-l> <C-W>l<C-E><C-W><C-W>
",tでタブを開く
map ,t :tabnew<CR>
"検索を画面の真ん中に
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz/
"visual modeで選択中のテキストを*で検索
vnoremap <silent> * "vy/\V<C-r>=substitute(escape(@v,'\/'),"\n",'\\n','g')<CR><CR>
"INSERT MODE中のCTRL+u,CTRL+wをundoできるようにする
inoremap <C-u> <C-g>u<C-u>
inoremap <C-w> <C-g>u<C-w>
"コンパイラの指定
autocmd FileType perl,cgi :compiler perl
"プラグイン--------------------------------------------------------------------------
"chalice
set runtimepath+=$VIM/chalice
"autocomplpop.vim
let g:acp_ignorecaseOption = 1
let g:acp_completeOption = '.,w,b,u,k,i,t'
let g:acp_completeoptPreview = 1
let g:acp_behaviorRubyOmniMethodLength = 0
let g:acp_behaviorRubyOmniSymbolLength = 0
let g:acp_behaviorPythonOmniLength = 0
let g:acp_behaviorXmlOmniLength = 0
let g:acp_behaviorHtmlOmniLength = 0
let g:acp_behaviorCssOmniPropertyLength = 0
let g:acp_behaviorCssOmniValueLength = 0
let g:acp_behaviorSnipmateLength=1
"BufBuf
nnoremap <silent> <F3> <Esc>:call BufBufLauncher(2)<CR>
"command-----------------------------------------------------------------------------
"_vimrcリロード
command! ReloadVimrc source $MYVIMRC
command! ReloadGVimrc source $MYGVIMRC
".vimrc自動リロード
"if !has('gui_running') && !(has('win32') || has('win64'))
" " .vimrcの再読込時にも色が変化するようにする
" autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
"else
" " .vimrcの再読込時にも色が変化するようにする
" autocmd MyAutoCmd BufWritePost $MYVIMRC source $MYVIMRC |
" \if has('gui_running') | source $MYGVIMRC
" autocmd MyAutoCmd BufWritePost $MYGVIMRC if has('gui_running') | source $MYGVIMRC
"endif
"リネーム
"command! -nargs=1 -complete=file Rename f <args>|call delete(expand('#'))
"カレントディレクトリを編集中のファイルのディレクトリに変更
command! -nargs=? -complete=dir -bang CD call s:ChangeCurrentDir('<args>', '<bang>')
function! s:ChangeCurrentDir(directory, bang)
if a:directory == ''
lcd %:p:h
else
execute 'lcd' . a:directory
endif
if a:bang == ''
pwd
endif
endfunction
"Change current directory.
nnoremap <silent> <Space>cd :<C-u>CD<CR>
" Enable mouse support.
set mouse=a
" For screen.
if &term =~ "^screen"
augroup MyAutoCmd
autocmd VimLeave * :set mouse=
augroup END
" screenでマウスを使用するとフリーズするのでその対策
set ttymouse=xterm2
endif
if has('gui_running')
" Show popup menu if right click.
set mousemodel=popup
" Don't focus the window when the mouse pointer is moved.
set nomousefocus
" Hide mouse pointer on insert mode.
set mousehide
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment