vimの基本的な設定をする
ついに、IDE厨な僕もvimを使うことを強いられたので、巷で流行の設定くらい出来ないといけないなと思い、筆をとりました。
環境
- Ubuntu12.04LTS
- vim@7.3.429
やること
- NeoBundleの導入
- チョコっとキーバインディングの設定
- カラースキームの変更
NeoBundleとは
NeoBundleの導入
インストール
インストールは簡単で以下の通りです。$ mkdir -p ~/.vim/bundle git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim git clone https://github.com/Shougo/vimproc ~/.vim/bundle/vimproc
以下は、作者様のgithubからの.vimrcのSampleです。
set nocompatible " Be iMproved if has('vim_starting') set runtimepath+=~/.vim/bundle/neobundle.vim/ endif call neobundle#rc(expand('~/.vim/bundle/')) " Let NeoBundle manage NeoBundle NeoBundleFetch 'Shougo/neobundle.vim' " Recommended to install " After install, turn shell ~/.vim/bundle/vimproc, (n,g)make -f your_machines_makefile NeoBundle 'Shougo/vimproc' " My Bundles here: " " Note: You don't set neobundle setting in .gvimrc! " Original repos on github NeoBundle 'tpope/vim-fugitive' NeoBundle 'Lokaltog/vim-easymotion' NeoBundle 'rstacruz/sparkup', {'rtp': 'vim/'} " vim-scripts repos NeoBundle 'L9' NeoBundle 'FuzzyFinder' NeoBundle 'rails.vim' " Non github repos NeoBundle 'git://git.wincent.com/command-t.git' " Non git repos NeoBundle 'http://svn.macports.org/repository/macports/contrib/mpvim/' NeoBundle 'https://bitbucket.org/ns9tks/vim-fuzzyfinder' " ... filetype plugin indent on " Required! " " Brief help " :NeoBundleList - list configured bundles " :NeoBundleInstall(!) - install(update) bundles " :NeoBundleClean(!) - confirm(or auto-approve) removal of unused bundles " Installation check. NeoBundleCheck
この状態で、vimを立ち上げて:NeoBundeInstallで.vimrcに記述したプラグインがインストールされます。
簡単ですね。
また、上記のように削除したい場合は、.vimrcから記述を削除して:NeoBundleCleanとすればアンインストールされます。
チョコっとキーバインディングの設定
hjklの移動も良いのですが、Insertモードの時にEmacs風のキー移動がしたいと思ったので、設定してみました。
.vimrcにこんな記述をしました。
" Emacs-like keybind cnoremap <C-a> <Home> cnoremap <C-b> <Left> cnoremap <C-d> <Del> cnoremap <C-e> <End> cnoremap <C-f> <Right> cnoremap <C-h> <Backspace> cnoremap <C-k> <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR> inoremap <C-a> <Home> inoremap <C-b> <Left> inoremap <C-d> <Del> inoremap <C-e> <End> inoremap <C-f> <Right> inoremap <C-h> <Backspace> inoremap <C-k> <C-o> inoremap <C-n> <Down> inoremap <C-p> <Up>
カラースキームの変更
参考サイト様
題名とは異なるのですが、jellybeansにしてみます。
とはいっても、これもNeoBundleで管理できるみたいですね。
必要なplugin
NeoBundle 'ujihisa/unite-colorscheme'を追加して、好きなカラースキームのリポジトリも追加します。
今回なら、
NeoBun
dle 'nanotech/jellybeans.
vim'
ですね。
deaultでカラースキームの指定する場合は、
colorscheme jellybeans[カラースキーム名]
をそれぞれ、.vimrcに追加します。
要は、
NeoBundle 'nanotech/jellybeans.vim' " color scheme colorscheme jellybeans
こんな感じになるのでしょうか?
後は、NeoBundleInstallでプラグインをインストールして、vimを再起動させればOKですかね。
また、ujihisa/unite-colorscheme(Shougo/unite.vimが必要)を使用すると、vimの起動中にカラースキームを変更できます。
:Unite colorscheme -auto-preview
と、コマンドモードで入力すると
カラースキームの一覧が表示され、インタラクティブにプレビューすることができ、変更できます。
便利ですね。
これから、vimを使用する機会が増えそうなので、もっともっと精進していきます。
最後まで、お読み頂きありがとうございました。