Vimメモ

プラグインマネージャ(vundle)インストール

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

※ .vimrc に以下の Vundle.vim の部分を記述後、:PluginInstall でインストール

~/.vimrc

"""""""""""""""""""""""""""""
" 表示設定
"""""""""""""""""""""""""""""

syntax on
"set cursorline
"highlight Normal cterm=none ctermbg=black ctermfg=white
highlight cursorline term=reverse cterm=none ctermbg=gray ctermfg=white
highlight statusline cterm=none ctermbg=white ctermfg=blue
"highlight statusline cterm=none ctermbg=none ctermfg=none

set enc=utf-8
set fenc=utf-8
set fencs=utf-8,cp932,sjis,euc-jp

set title
set ignorecase
set smartcase
set wrapscan
set hlsearch
set incsearch
set number
"set laststatus=2
"set statusline=%F%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c
set ruler
set ts=4

" change tab space
set expandtab
set tabstop=4
set shiftwidth=4

if exists('&ambiwidth')
  set ambiwidth=double
endif

let _curfile=expand("%:r")
if _curfile == 'Makefile'
  set noexpandtab
endif

" Change Encoding Command
command! Utf8 edit ++enc=utf-8
command! Sjis edit ++enc=cp932
command! Cp932 edit ++enc=cp932
command! Win31j edit ++enc=cp932

"""""""""""""""""""""""""""""
" Jsonフォーマッタ
"""""""""""""""""""""""""""""
command! -nargs=? Jq call s:Jq(<f-args>)
function! s:Jq(...)
    if 0 == a:0 
        let l:arg = "." 
    else
        let l:arg = a:1 
    endif
    execute "%! jq \"" . l:arg . "\""
endfunction

command! JsonFormat :execute '%!python -m json.tool'
  \ | :execute '%!python -c "import re,sys;chr=__builtins__.__dict__.get(\"unichr\", chr);sys.stdout.write(re.sub(r\"\\u[0-9a-f]{4}\", lambda x: chr(int(\"0x\" + x.group(0)[2:], 16)), sys.stdin.read()))"'
  \ | :%s/ \+$//ge
  \ | :set ft=javascript
  \ | :1

"""""""""""""""""""""""""""""
" キーバインド
"""""""""""""""""""""""""""""
" n1, n0 で行番号の表示有無を切り替える
noremap n0 :<C-u>set nonumber<Enter>
noremap n1 :<C-u>set number<Enter>

" html, div 入力
noremap html <insert><!doctype html><Enter><html lang="ja"><Enter><head><Enter><meta charset="utf-8"><Enter></head><Enter><body><Enter><Enter></body><Enter></html><UP><UP><Esc>
noremap div <insert><div id="" class="" style=""><Enter><Enter></div><UP><Esc>

" ファイル新規作成時の定型文自動挿入
autocmd BufNewFile *.php 0r $HOME/.vim/template/php.txt
autocmd BufNewFile *.html 0r $HOME/.vim/template/html.txt

"""""""""""""""""""""""""""""
" Vundle.vim
"""""""""""""""""""""""""""""
set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
call vundle#end()            " required
filetype plugin indent on    " required

"""""""""""""""""""""""""""""
" vim-airline
"""""""""""""""""""""""""""""
set laststatus=2
let g:airline#extensions#branch#enabled = 0
"let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"


トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-09-06 (木) 00:47:04 (102d)