2011年9月29日木曜日

[Vim] VimでRuby on Rails開発

■Vim/Ruby
cd /usr/local/src/
git clone http://github.com/vim-ruby/vim-ruby.git
cd vim-ruby
mv INSTALL.markdown INSTALL
rake package

※エラーが出た場合(rake 0.9以降)
vim Rakefile
------------------------------------------------
+#require 'rake/gempackagetask'
+require 'rubygems/package_task'

+#Rake::GemPackageTask.new(gemspec) do |t|
+Gem::PackageTask.new(gemspec) do |t|
------------------------------------------------

# {yyyy.MM.dd}は今日の日付
gem install etc/package/vim-ruby-{yyyy.MM.dd}.gem

vim ~/.vimrc
------------------------------------------------
set nocompatible
filetype on
filetype indent on
filetype plugin on
set expandtab
set autoindent

"----------------------------------------------------
" vim-rubyの設定
"----------------------------------------------------
"でomni補完
imap

let ruby_space_errors=1

"Rubyのオムニ補完を設定(ft-ruby-omni)
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
------------------------------------------------


■rails.vim
wget -O ~/.vim/rails.zip http://www.vim.org/scripts/download_script.php?src_id=16429
cd ~/.vim
unzip rails.zip
rm -rf rails.zip

■project.vim
wget -O ./project-1.4.1.tar.gz http://www.vim.org/scripts/download_script.php?src_id=6273
tar -xvf ./project-1.4.1.tar.gz -C ~/.vim
rm -rf ./project-1.4.1.tar.gz

vim ~/.vimrc
------------------------------------------------
"----------------------------------------------------
" rails.vimの設定(rails.vim)
"----------------------------------------------------
let g:rails_level = 4
let g:rails_devalut_database = 'mysql'
------------------------------------------------

■matchit.vim
wget -O ~/.vim/matchit.zip http://www.vim.org/scripts/download_script.php?src_id=8196
cd ~/.vim
unzip matchit.zip
rm -rf matchit.zip


■surround.vim
wget -O ~/.vim/surround.zip http://www.vim.org/scripts/download_script.php?src_id=12566
cd ~/.vim
unzip surround.zip
rm -rf surround.zip

■snippetEmu.vim
wget -O ~/snippy_plugin.vba http://www.vim.org/scripts/download_script.php?src_id=8450
vim snippy_plugin.vba
------------------------------------------------
:source %
------------------------------------------------
rm -rf snippy_plugin.vba

■NERD_commenter.vim
wget -O ~/.vim/nerdcommenter.zip http://www.vim.org/scripts/download_script.php?src_id=14455
cd ~/.vim
unzip nerdcommenter.zip
rm -rf nerdcommenter.zip

■autocomplpop.vim

wget -O ~/.vim/vim-autocomplpop.zip http://www.vim.org/scripts/download_script.php?src_id=11894
cd ~/.vim
unzip vim-autocomplpop.zip
rm -rf vim-autocomplpop.zip


■vimrcの設定
vim ~/.vimrc
------------------------------------------------
"タブ幅をリセット
au BufNewFile,BufRead * set tabstop=4 shiftwidth=4
".rhtmlと.rbと.ymlでタブ幅を変更
au BufNewFile,BufRead *.rhtml set tabstop=2 shiftwidth=2
au BufNewFile,BufRead *.rb set tabstop=2 shiftwidth=2
au BufNewFile,BufRead *.yml set tabstop=2 shiftwidth=2
"Rails関連ファイルで文字コードをUFT-8に設定
au User Rails* set fenc=utf-8
------------------------------------------------

0 件のコメント:

コメントを投稿