Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created September 26, 2015 01:31
Show Gist options
  • Save mactkg/6826b2517f67f71690e3 to your computer and use it in GitHub Desktop.
Save mactkg/6826b2517f67f71690e3 to your computer and use it in GitHub Desktop.
light version
filetype plugin indent on
filetype indent on
" Visualize
syntax enable
set cursorline
" Informations
set ruler number
set showcmd
set list
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%
" tab
set smarttab
set expandtab
set tabstop=2
set shiftwidth=2
set shiftround
set ambiwidth=double
" indent
set autoindent
set smartindent
set cindent
set shiftround
set backspace=2
set virtualedit=all
" search
set showmatch
set wrapscan
set incsearch
set hlsearch
set ignorecase
set smartcase
" command
set wildmode=longest:full,full
set wildmenu
set shellslash
set cinoptions+=:0,g0 " don't indent when I make a label
set hlsearch
noremap <Esc><Esc> :nohlsearch<CR><Esc>
set infercase
" backup / swap
set nowritebackup
set nobackup
set noswapfile
" format
set encoding=utf-8
set fileformats=unix,dos,mac
set fileencoding=utf=8
set ambiwidth=double
" auto recognize of char code
if &encoding !=# 'utf-8' " utf-8をデフォルトに
set encoding=japan
set fileencoding=japan
endif
if has('iconv')
let s:enc_euc = 'euc-jp'
let s:enc_jis = 'iso-2022-jp'
" iconvがeucJP-msに対応しているかをチェック
if iconv("¥x87¥x64¥x87¥x6a", 'cp932', 'eucjp-ms') ==# "¥xad¥xc5¥xad¥xcb"
let s:enc_euc = 'eucjp-ms'
let s:enc_jis = 'iso-2022-jp-3'
" iconvがJISX0213に対応しているかをチェック
elseif iconv("¥x87¥x64¥x87¥x6a", 'cp932', 'euc-jisx0213') ==# "¥xad¥xc5¥xad¥xcb"
let s:enc_euc = 'euc-jisx0213'
let s:enc_jis = 'iso-2022-jp-3'
endif
" fileencodingsを構築
if &encoding ==# 'utf-8'
let s:fileencodings_default = &fileencodings
let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932'
let &fileencodings = &fileencodings .','. s:fileencodings_default
unlet s:fileencodings_default
else
let &fileencodings = &fileencodings .','. s:enc_jis
set fileencodings+=utf-8,ucs-2le,ucs-2
if &encoding =~# '^¥(euc-jp¥|euc-jisx0213¥|eucjp-ms¥)$'
set fileencodings+=cp932
set fileencodings-=euc-jp
set fileencodings-=euc-jisx0213
set fileencodings-=eucjp-ms
let &encoding = s:enc_euc
let &fileencoding = s:enc_euc
else
let &fileencodings = &fileencodings .','. s:enc_euc
endif
endif
let &fileencodings = 'utf-8' . ',' . &fileencodings " XXX: adhocな対応
" 定数を処分
unlet s:enc_euc
unlet s:enc_jis
endif
" if no Japanese => use encoding for fileencoding
if has('autocmd')
function! AU_ReCheck_FENC()
if &fileencoding =~# 'iso-2022-jp' && search("[^¥x01-¥x7e]", 'n') == 0
let &fileencoding=&encoding
endif
endfunction
autocmd BufReadPost * call AU_ReCheck_FENC()
endif
" suffix
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
" keybind
noremap ; :
noremap : ;
nnoremap <silent><C-e> :NERDTreeToggle<CR>
" move
nnoremap <Tab> %
vnoremap <Tab> %
" template
autocmd BufNewFile *.pl 0r $HOME/.vim/template/perl-script.txt
autocmd BufNewFile *.pm 0r $HOME/.vim/template/perl-script.txt
autocmd BufRead *.psgi set filetype=perl
autocmd BufNewFile,BufRead *.pm set filetype=perl
autocmd BufNewFile *.t 0r $HOME/.vim/template/perl-test.txt
autocmd BufNewFile,BufRead *.t set filetype=perl
" coffee
autocmd FileType coffee setlocal sw=2 sts=2 ts=2 et
au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee
" md is markdown
autocmd BufRead,BufNewFile *.md set filetype=markdown
if exists('&ambiwidth')
set ambiwidth=double
endif
" arduino
au BufRead, BufNewFile *.ino set filetype=arduino
" cpp
augroup cpp-path
autocmd!
autocmd FileType cpp setlocal path=.,/usr/include,/usr/local/include,/usr/lib/c++/v1
augroup END
" PHP
autocmd FileType php,ctp :set dictionary=~/.vim/dict/php.dict
autocmd BufNewFile,BufRead *.js set tabstop=2 shiftwidth=2 expandtab
set tags+=tags,Gemfile.lock.tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment