我在高雄市 (台灣) 獲得了 Vim 餅乾的小禮物!
— 凍仁翔 (@chusiang_lai) February 7, 2016
I get the gift of '#Vim biscuit' at #Kaohsiung City, #Taiwan .#VimTaiwan pic.twitter.com/CaPII8ibLf
1. 安裝 Vim。
# Debian, Ubuntu.
[ jonny@trusty ~ ]
$ sudo apt-get install vim [Enter]
# OSX.
[ jonny@ei_capitan ~ ]
$ brew install vim [Enter]
2. 將預設編輯器從 nano 改為 Vim (適用於 Debian, Ubuntu)。
[ jonny@trusty ~ ]
$ sudo update-alternatives --config editor [Enter]
There are 3 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ * 0 /bin/nano 40 auto mode 1 /bin/nano 40 manual mode 2 /usr/bin/vim.basic 30 manual mode 3 /usr/bin/vim.tiny 10 manual mode Press enter to keep the current choice[*], or type selection number: 2 [Enter] update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode
3. 我們也可改用單行指令來更換預設編輯器,這對常撰寫部署系統 script 的凍仁來說可是必備的呢!(適用於 Debian, Ubuntu)
[ jonny@trusty ~ ]
$ sudo update-alternatives --set editor /usr/bin/vim.basic [Enter]
4. 將環境變數 EDITOR 設為 Vim。在使用 visudo 等會呼叫預設編輯器的指令時,若沒特別指定則可能會用非 Vim 編輯器開啟。(通用)
[ jonny@trusty ~ ]
$ echo 'export EDITOR=vim' >> ~/.bashrc; source ~/.bashrc [Enter]
5. 真受不了也可開大決把其它 editor 都砍了 (不建議,只適用本機測試環境)。
[ jonny@trusty ~ ]
$ sudo apt-get purge nano joe ... [Enter]
6. 在 Bash 使用 vi 模式。(通用)
[ jonny@trusty ~ ]
$ echo 'set -o vi' >> ~/.bashrc [Enter]
7. 在其它的 Shell 使用 vi 模式,例如 MySQL & Python Shell。(通用)
[ jonny@trusty ~ ]
$ echo 'set editing-mode vi' >> ~/.inputrc [Enter]
努力學習 Vim,一同邁向 Vimmer 大師之路! #《學徒模式》
相關連結:
★ chusiang.vim-and-vi-mode | Ansible Galaxy
★ Ansible Role: Install Vim and use vi-mode in everyway. | GitHub
資料來源:
★ Change the Default Editor From Nano on Ubuntu Linux
★ Set Default Text Editor For Crontab To VIM | Sany's Linux and Open Source Blog
★ Using the Python shell in Vi mode on Windows - Stack Overflow
★ unix - How to get vi keybindings to work in mysql client? - Stack Overflow
沒有留言 :
張貼留言
喜歡這篇文章嗎?歡迎在底下留言讓凍仁知道。😉