プラグイン管理
プラグイン管理には NeoBundle を使っています。
https://github.com/Shougo/neobundle.vim
カラースキーマ
molokai
https://github.com/tomasr/molokai
これ一択ですね!
こんな感じ。
プラグイン
Align
http://www.vim.org/scripts/script.php?script_id=294
インデントの修正などの様々な整形が行える。
hail2u/vim-css3-syntax
https://github.com/hail2u/vim-css3-syntax
CSS3シンタックス。
kien/ctrlp.vim
https://github.com/kien/ctrlp.vim
ファイルの絞込。
kchmck/vim-coffee-script
https://github.com/kchmck/vim-coffee-script
CoffeeScriptのシンタックス、インデント、コンパイル。
Lokaltog/vim-powerline
https://github.com/Lokaltog/vim-powerline
ステータスラインをかっこよく。
mattn/emmet-vim
https://github.com/mattn/emmet-vim
Zen-codingの後継。
minibufexpl.vim
http://www.vim.org/scripts/script.php?script_id=159
タブエディタ風にバッファ管理ウィンドウを表示。
osyo-manga/vim-over
https://github.com/osyo-manga/vim-over
文字列の一置換時に置換前文字列をハイライトし、変換後文字列が横に出てくる。
Shougo/neosnippet
https://github.com/Shougo/neosnippet.vim
スニペット機能。
Shougo/unite.vim
https://github.com/Shougo/unite.vim
Shougo/vimproc
https://github.com/Shougo/vimproc.vim
Vimで非同期実行する。
Shougo/vimshell.git
https://github.com/Shougo/vimshell.vim
Vimからシェルを起動する。
slim-template/vim-slim
https://github.com/slim-template/vim-slim
slimのシンタックス。
taichouchou2/html5.vim
https://github.com/alpaca-tc/html5.vim
HTML5シンタックス。
thinca/vim-quickrun
https://github.com/thinca/vim-quickrun
編集中のソースコードを実行して実行結果をVimへ出力する。
thinca/vim-ref
https://github.com/thinca/vim-ref
Vimからリファレンスを引けるように。
The-NERD-tree
http://www.vim.org/scripts/script.php?script_id=1658
ツリー型エクスプローラ。
tpope/vim-rails
https://github.com/tpope/vim-rails
Railsの開発では必須。
tpope/vim-surround
https://github.com/tpope/vim-surround
vimのテキストオブジェクトを拡張する。
tyru/open-browser.vim
https://github.com/tyru/open-browser.vim
URLを開いたり、ググったりできる。
vim-ruby/vim-ruby
https://github.com/vim-ruby/vim-ruby
シンタックスやインデント。
文字コード、改行コード
set encoding=utf-8 set fileformats=unix,dos,mac
Leader
let mapleader=","
<Leader> を 「,」にする。
カラー設定
シンタックスハイライト
syntax enable を設定しておくとカラー表示になります。
カラー端末の時だけこの設定を有効にしたい場合
if &t_Co > 1 syntax enable endif colorscheme molokai
※ colorscheme は syntax enable のあとに定義すること。
基本設定
autoindent
set autoindent
自動インデントモード。
autoread
set autoread
変更のあったファイルを自動的に読み直す。
backspace
set backspace=indent,eol,start
バックスペースキーで削除できるものを指定する。
- indent: オートインデントの空白文字。
- eol: 改行。
- start: インサートモード開始位置より手前の文字。
clipboard
set clipboard=unnamed
コピー/ペーストを行なった場合は クリップボードを利用する。
cursorline
set cursorline
カレント行をハイライトする 。 重い...
hidden
set hidden
保存されていないファイルがあるときでも別のファイルを開くことが出来るようにする。
history
set history=50
コマンド・検索パターンの履歴数。
laststatus
set laststatus=2
常にステータラスラインを表示する。
list
set list
不可視文字を表示する。
listchars
set listchars=tab:>-,trail:-,extends:>,precedes:<
不可視文字の表示方法を指定する。
set list が設定されている場合有効になる。
modelines
set modelines=0
モードラインを無効にする。
backup
set backup set backupdir=~/.vim/backups
出力先を指定してバックアップファイルを作成する。
backupを無効にする場合
set nobackup
swapfile
set swapfile set directory=~/.vim/swaps
出力先を指定してスワップファイルを作成する。
swapfileを無効にする場合
set noswapfile
number
set number
行番号を表示する。
ruler
set ruler
ルーラーを表示する。
scrolloff
set scrolloff=5
スクロール時の余白を5行分確保する。
showcmd
set showcmd
コマンドをステータス行に表示する。
showmatch
set showmatch
対応する括弧をハイライト。
showmode
set showmode
現在のモードを表示する。
smartindent
set smartindent
改行時に入力された行の末尾に合わせて次の行のインデントを増減する。
suffixes
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
ワイルドカードで表示するときに優先度を低くする拡張子を指定する。
textwidth
set textwidth=0
0でないなら、このオプションで設定された幅で行を改行する。
title
set title
タイトルを表示する。
ttyfast
set ttyfast
高速ターミナル接続を行う。
vb t_vb
set vb t_vb=
ビープ音を鳴らさないようにする。
whichwrap
set whichwrap=b,s,h,l,<,>,[,]
カーソルを行頭、行末で止まらないようにする。
wildchar
set wildchar=<tab>
コマンド補完開始キー。
wildmenu
set wildmenu
コマンド補完を強化。
wildmode
set wildmode=list:longest
リスト表示方法。
検索系設定
incsearch
set incsearch
インクリメンタルサーチ。
ignorecase
set ignorecase
大文字小文字無視する。
hlsearch
set hlsearch
検索文字をハイライトする。
smartcase
set smartcase
大文字は区別する。
インデント設定
tabstop
set tabstop=2
タブを画面に表示する際の幅。
shiftwidth
set shiftwidth=2
インデント時に使用されるスペースの数。
expandtab
set expandtab
タブを挿入する時、そのタブを半角スペースとして挿入する。
smarttab
set smarttab
行頭の余白内で Tab を打ち込むと、shiftwidth の数だけインデントする。
便利設定
ウィンドウ操作
「:vs」や「:sp」でウィンドウを分割した場合の操作。
「sh で左のウィンドウに移動
nnoremap sh <C-w>h
「sj」 で下のウィンドウに移動
nnoremap sj <C-w>j
「sk」 で上のウィンドウに移動
nnoremap sk <C-w>k
「sl」 で右のウィンドウに移動
nnoremap sl <C-w>l
「+」 でカーソル位置のウィンドウを高くする
nnoremap + <C-w>+
「-」 でカーソル位置のウィンドウを低くする
nnoremap - <C-w>-
「)」 でカーソル位置のウィンドウの横幅を広くする
nnoremap ) <C-w>>
「(」 でカーソル位置のウィンドウの横幅を狭くする
nnoremap ( <C-w><LT>
タブ操作
「T」 でタブを新規作成する
nmap T :tabnew<CR>
「,tx」 でタブを閉じる
nmap <leader>tx :tabclose<CR>
「,tp」 で前のタブに移動する
nmap <leader>tp :tabprevious<CR>
「,tn」 で次のタブに移動する
nmap <leader>tn :tabNext<CR>
どこでも「Space + ev」で.vimrc を編集できるようにする
nnoremap <silent> <Space>ev :<C-u>edit $MYVIMRC<CR>
どこでも「Space + eg」で.gvimrc を編集できるようにする
nnoremap <silent> <Space>eg :<C-u>edit $MYGVIMRC<CR>