修改Ubuntu终端中,Vim插入模式下光标实现为竖线状
来源:互联网 发布:微社区 源码 编辑:程序博客网 时间:2024/06/06 00:28
原文:Change cursor shape in different modes
不同终端版本修改代码不同。
使用如下命令查看Gnome-Terminal终端的版本:
aptitude show gnome-terminal
To change the shape of the cursor in different modes, you can add the following into your vimrc.
将不同版本终端对应的代码添加到vimrc文件中即可。
我的终端版本为3.18***,vimrc文件位于etc/vim/vimrc
For the Gnome-Terminal (version 2.26)Edit
This makes your cursor change in all open terminals. Upgrade your terminal and use the version above instead.
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
For the Gnome-Terminal (version 3.x)Edit
First make a script gnome-terminal-cursor-shape.sh
#!/bin/shDEFAULTPROF=`dconf read /org/gnome/terminal/legacy/profiles:/default`DEFAULTPROF=`echo "$DEFAULTPROF" | sed -e "s/^'/:/" -e "s/'$//"`dconf write /org/gnome/terminal/legacy/profiles:/$DEFAULTPROF/cursor-shape "'$1'"
Make it executable & put it in /usr/local/bin Next, add this to .vimrc
if has("autocmd") au InsertEnter * \ if v:insertmode == 'i' | \ silent execute "!gnome-terminal-cursor-shape.sh ibeam" | \ elseif v:insertmode == 'r' | \ silent execute "!gnome-terminal-cursor-shape.sh underline" | \ endif au InsertLeave * silent execute "!gnome-terminal-cursor-shape.sh block" au VimLeave * silent execute "!gnome-terminal-cursor-shape.sh block"endif
If you use more than one profile in gnome-terminal, you might have to adapt this to your profiles.
For the Gnome-Terminal (version ≥3.16) Edit
This method has the advantage compared to the method above that it influences the given tab only, and not all the tabs that use the given profile. Add the following into .vimrc
if has("autocmd") au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw! au InsertEnter,InsertChange * \ if v:insertmode == 'i' | \ silent execute '!echo -ne "\e[6 q"' | redraw! | \ elseif v:insertmode == 'r' | \ silent execute '!echo -ne "\e[4 q"' | redraw! | \ endif au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!endif
Above snippet disables cursor blinking. If you want cursor blink, just decrement all the 3 numbers above 2,4,6 by one each.
if has("autocmd") au VimEnter,InsertLeave * silent execute '!echo -ne "\e[1 q"' | redraw! au InsertEnter,InsertChange * \ if v:insertmode == 'i' | \ silent execute '!echo -ne "\e[5 q"' | redraw! | \ elseif v:insertmode == 'r' | \ silent execute '!echo -ne "\e[3 q"' | redraw! | \ endif au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!endif
- 修改Ubuntu终端中,Vim插入模式下光标实现为竖线状
- [转]Ubuntu下两个小细节的调整,如何将vim光标设置为竖线
- 将 Ubuntu 终端下默认编辑器修改为 Vim
- vim中,在插入模式,迅速让光标跳入下一行(生成新一行)
- Ubuntu & CentOS 禁止终端terminal和vim的光标闪烁
- vim 编辑模式下光标移动快捷键
- ubuntu 下vim修改tab键为4个空格
- ubuntu 下vim修改tab键为4个空格
- ubuntu终端光标形状
- 终端下vim中的汉字为乱码
- 终端下vim中的汉字为乱码
- Ubuntu终端光标形状切换
- Ubuntu终端光标形状切换
- ubuntu下终端路径显示的修改
- Ubuntu修改终端下的语言
- Ubuntu 终端下路径太长修改办法
- Ubuntu 下的 VIM 中,如何在终端之间复制代码(文字)
- 修改ubuntu默认编辑器为vim
- android 之OkHttp封装模板
- matrix67系列好文
- python可以玩的海龟(turtle)画图软件
- 软件工程(C编码实践篇)学习总结
- 热键
- 修改Ubuntu终端中,Vim插入模式下光标实现为竖线状
- 线性表的顺序存储结构的常见操作(C语言代码实现)
- Noip2017提高组 退役记
- sdnu 1099
- zoj 2314 reactor cooling(无源汇有上下界可行流)
- Codejam之Alphabet Cake
- android runtime 创建流程
- 九九乘法表
- KindEditor使用技巧