剛從windows轉到linux的用戶可能都有一個不爽的地方,就是終端和vim中光標都是一個字符的寬度,很粗,在輸入的時候很容易找不到當前輸入的字符會出現在哪兩個字符中間。
於是乎,為了眼睛痛快、頭腦清爽,我查了一下如何改變終端中光標的形狀。在這里總結一下。
因為我的初衷是使vim的光標改變,所以使用的辦法是在.vimrc中寫些代碼
方法(一)
在當前用戶的./vimrc文件中添加如下代碼。效果是終端中所有的光標都變細,也就是說vim普通模式和插入模式都是細光標
"使得terminal的光標變為細線,而不是默認的粗條。這個在vim的普通模式和插入模式都會生效。 set gcr=n-v-c:ver25-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor
方法(二)
在當前用戶的./vimrc文件中添加如下代碼。效果是,在vim的插入模式時光標變細。
if has("autocmd") au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam" au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block" au VimLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam" endif
參考資料:
http://blog.sina.com.cn/s/blog_ac9fdc0b0101ol0b.html
http://blog.csdn.net/xiaohui5319/article/details/7507042
十分感謝原作者!