安裝 vim
剛裝好的 Ubuntu (10.04), 只有 vi。
打開終端機輸入
>>> sudo apt-get install vim
簡單設定 vim (vimrc)
透過編輯家目錄底下的 .vimrc ( $HOME/.vimrc or ~/.vimrc ), 可以客製化 vim 的使用環境。
在 /etc/vim/ 資料夾裡,有一 vimrc 範例,
>>> vi /etc/vim/vimrc
顯示行號 設定 讓 vim 記得檔案上次編輯位置
譬如,我想要編輯檔案的時候, 會顯示行號以及 編輯一份檔案離開後, 下次再進入編輯,可以從上次的位置繼續工作。 那麼只要將下列的內容放入 ~/.vimrc 裡頭即可。
>>> vi ~/.vimrc or >>> gedit ~/.vimrc
set nu " Uncomment the following to have Vim jump to the last position when " reopening a file if has("autocmd") au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") \| exe "normal g'\"" | endif endif
Refs
` vim, how to set cursor to return to previous position at reedit <http://ubuntuforums.org/showthread.php?t=789327>`_
` 主題: vim-回到上次所編輯文件的位置 <http://phorum.study-area.org/index.php?topic=52794.0>`_