[已解决]我的vim在某些情况下异常频繁读写硬盘

Vim、Emacs配置和使用
回复
reallynotme
帖子: 157
注册时间: 2010-11-11 18:13
系统: Ubuntu

[已解决]我的vim在某些情况下异常频繁读写硬盘

#1

帖子 reallynotme » 2012-11-04 17:22

如果不用寄存器的重复动作功能倒没什么感觉,但是用的话即使动作里不包括读写操作,有时候vim却会异常频繁的读写硬盘.我另外在虚拟机里的ubuntu和windows下试了,读写硬盘的现象却没出现.不知道是设置的原因还是虚拟机缓存硬盘操作的原因.大家帮忙看看,硬盘灯狂闪太不爽了,而且也严重影响命令执行的速度

测试方法如下:
测试文件是一个包含100行以下文字的文件

代码: 全选

abcd 0x1234
结果是把100行都转为

代码: 全选

case 0x1234://abcd
这是转换用的代码:

代码: 全选

:exe "1,100normal ^cecase\<esc>A://\<esc>pj" 
在我这里的现象是硬盘灯狂闪,而且能听到硬盘的声音,操作共费时14秒
而在虚拟机里,这个操作是瞬间完成的,而且硬盘灯也不闪
另外如果用正则表达式做的话也不会出现这种情况
上次由 reallynotme 在 2012-11-04 19:41,总共编辑 1 次。
头像
Fermat618
帖子: 728
注册时间: 2008-12-28 16:01

Re: 我的vim在某些情况下异常频繁读写硬盘

#2

帖子 Fermat618 » 2012-11-04 19:09

可能是在写交换文件吧。你升级下 vim 试试,说不定是某个 bug.
爱因斯坦会弹钢琴
爱因斯坦会拉小提琴
爱因斯坦会骑自行车
reallynotme
帖子: 157
注册时间: 2010-11-11 18:13
系统: Ubuntu

Re: 我的vim在某些情况下异常频繁读写硬盘

#3

帖子 reallynotme » 2012-11-04 19:40

自己解决了

我用root运行vim发现就没这问题,猜可能是.vimrc的事
然后把里面这一小段代码注释掉就没事了

代码: 全选

"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
这个代码是网上找的用来让bash中的vim也能改变光标样式的(事实上并不好使)
头像
Fermat618
帖子: 728
注册时间: 2008-12-28 16:01

Re: 我的vim在某些情况下异常频繁读写硬盘

#4

帖子 Fermat618 » 2012-11-04 23:45

reallynotme 写了:自己解决了

我用root运行vim发现就没这问题,猜可能是.vimrc的事
然后把里面这一小段代码注释掉就没事了

代码: 全选

"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
这个代码是网上找的用来让bash中的vim也能改变光标样式的(事实上并不好使)
原来是加了个自动命令来运行外部程序,难怪。

我是早习惯了平时在普通模式了,进入插入模式是短暂的,所以没有多少搞不清当前模式的机会。
爱因斯坦会弹钢琴
爱因斯坦会拉小提琴
爱因斯坦会骑自行车
reallynotme
帖子: 157
注册时间: 2010-11-11 18:13
系统: Ubuntu

Re: 我的vim在某些情况下异常频繁读写硬盘

#5

帖子 reallynotme » 2012-11-05 9:05

Fermat618 写了:
reallynotme 写了:自己解决了

我用root运行vim发现就没这问题,猜可能是.vimrc的事
然后把里面这一小段代码注释掉就没事了

代码: 全选

"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
这个代码是网上找的用来让bash中的vim也能改变光标样式的(事实上并不好使)
原来是加了个自动命令来运行外部程序,难怪。

我是早习惯了平时在普通模式了,进入插入模式是短暂的,所以没有多少搞不清当前模式的机会。
用惯了gvim用vim实在是受不了那光标
回复