一覧 最終更新 HOME ログイン

freedomcat.com

vim

[cygwin]

参考

vimインストール

.vimrc

vimキーバインド

プラグイン

viでやりたいこと

vi(vim)は、今回のcygwin導入の要だ。viを通して、テキストを編集したり、プログラムを書いたり、システムを動かしたいので、ruby、perl、pythonとはなるべくシームレスに連携してほしい。

postmail.vim : メール送信用vimエディタプラグインCygwin上のVimとirbでRubyプログラミングを読むと、viにrubyやpythonをプラグインとして組み込み、それによって動かし方の幅が広がりそうなことがわかった。

それには、次の要件が必要そうだ。

最後の用件は、viとは関係なく、それぞれがインストールされ、パスが通されていればokだろう。

問題は、'compatible','+python', '+iconv', '+multi_byte','+ruby'オプション付きでどうviをコンパイルするか、だ。コンパイル方法がわからない。

postmail.vim : メール送信用vimエディタプラグインで紹介されているのは、オプションが付いているかどうかの判断方法だけだ。

'+python'、'+iconv'、'+multi_byte'付きでコンパイルされたVimエディタを使用していますか? 
次のコマンドを実行して、Vimエディタのコンパイルオプションを調べてください。 
'+python'、'+iconv'、'+multi_byte'が見つかればOKです。

:version

デフォルトの環境(Setup.exeからインストールしたvim)の結果は次のとおりだった。

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 11 2010 17:36:58)
Included patches: 1-264
Compiled by http://cygwin.com/
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv
+cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra
 +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork()
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
+linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse
-mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra
-perl +postscript +printer +profile -python +quickfix +reltime +rightleft -ruby
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace
+wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard
-xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim.exe       -lm -lncurses  -liconv

rubyもperlもpythonも「-」です……。

ここで少し悩んだ(というか遠い記憶を呼び起こすのに時間がかかった)。*nix系のソフトの入れ方ってどうしてたっけ?

わたしの経験では(もう10年近く前だ)、*nix系のソフトは、コンパイル(make)する時に、そのマシンごとに固有な環境(path)を設定/指定(configure)してから、コンパイルしていた。コンパイルと一言で言っても、次の3ステップを踏む。

  1. configure (環境設定=パスやオプションの指定)
  2. make (コンパイル=実行権限のあるバイナリファイルを作る)
  3. install (binなどpathの通った場所に実行権限のあるバイナリファイルをコピーする)

まずはconfigureだ。

$./configure --enable-rubyinterp

走らせてみた結果がこのログファイルである。vim_configure.log(1190)

最初に'compatible'で検索した。

23 checking for sys/wait.h that is POSIX.1 compatible... yes

ここしか'compatible'は出てこない。そして'yes'になっているからおそらく設定は不要だ。

次に各オプションだ。

パラメータを与えた'ruby'。

52 checking --enable-rubyinterp argument... yes
53 checking for ruby... /usr/bin/ruby
54 checking Ruby version... OK
55 checking Ruby header files... /usr/lib/ruby/1.8/i386-cygwin

configureするときに'--enable-rubyinterp'を与えたために、'yes'の応答がきて、rubyのpath(/usr/bin/ruby)やバージョンチェック(OK)、ヘッダーファイルのチェックをしてくれている。なるほど。'--enable-rubyinterp'という具合にconfigureする時にパラメータを与えればいいんだな。

次に'perl'と'python'。これは何もパラメータを与えてない。

49 checking --enable-perlinterp argument... no
50 checking --enable-pythoninterp argument... no

チェックで'no'が戻ってきている。これは'--enable-perlinterp'と'--enable-pythoninterp'を与えよう。

それから'iconv'。

124 checking iconv.h usability... yes
125 checking iconv.h presence... yes
126 checking for iconv.h... yes

これは'yes'が戻ってきているのでパラメータを与えなくても今の環境で大丈夫そうだ。

そして、'multi_byte'。これは検索してもconfigureには出てこなかった。バイナリ版では+だった。makeしないとどうなるかわからないな。

vimインストール編

vimのconfigure設定に次のようなサンプルがあった。

# ./configure --enable-rubyinterp --without-x --disable-gui  --with-features=big

今回、'+python'、'+iconv'、'+multi_byte'、'ruby'オプションがつくとよいので、上記のコマンドを次のように改変した。

./configure --enable-rubyinterp --enable-perlinterp --enable-pythoninterp --enable-multibyte --without-x --disable-gui --with-features=big

また、まさはる's Weblog: Vim-6.1のインストール(その2)を観るとiconvオプションをつけるには次のような設定が必要らしい。

$ cd vim/src/
$ autoconf -o auto/configure

そこで、次のような手順で、インストールをした。

$cd /tmp/vim-7.2.264-2
$autoconf -o auto/configure
$cd ..
$./configure --enable-rubyinterp --enable-perlinterp --enable-pythoninterp --enable-multibyte --without-x --disable-gui --with-features=big
$make
$make install
$cd /usr/bin
$ln -s /usr/local/bin/vim.exe vim.exe
$cd $HOME
==$.vimrc==
==alias vi=vim==
$ln -s /usr/local/bin/vim.exe vi

aliasでのviだと、w3mがvimをエディタとして使えないため、vim.exeからのシンボリックリンクに変更。

versionの確認

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 19 2010 22:47:21)
Included patches: 1-264
Compiled by shino@SHINO-PC
Big version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv
+cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra
 +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork()
+gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
+linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse
-mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm ''+multi_byte'' +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra
''-perl'' +postscript +printer -profile ''+python'' +quickfix +reltime +rightleft ''+ruby''
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace
+wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard
-xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2     -I/usr/include/python2.5 -p
thread  -I/usr/lib/ruby/1.8/i386-cygwin
Linking: gcc   -L.   -L/usr/local/lib -o vim.exe       -lm -lncurses   -liconv -lintl    -
L/usr/lib/python2.5/config -lpython2.5  -lruby -ldl -lcrypt

'+ruby','+python','+iconv','+multi_byte'きている!よし。perlだけがうまくいってないけれど、とりあえず保留でいいかな。