Vim全部替换而无需移动光标 [英] Vim replace all without cursor moving

查看:57
本文介绍了Vim全部替换而无需移动光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vim中,当我这样做时:

:%s/foo/bar/g

它将在整个文档中用"bar"替换所有出现的"foo".完成后,光标将移动到最后一个位置,在该位置上,"foo"被替换为"bar".

在发出此命令之前,如何在没有光标离开原始位置的情况下运行:%s/foo/bar/g?

我可以在.vimrc文件中设置一些选项吗?

解决方案

我只需在替换后键入 Ctrl + O 即可返回到先前的位置.

In Vim, when I do:

:%s/foo/bar/g

It will replace all occurrence of 'foo' with 'bar' in the entire document. When it completes, the cursor has moved to the last position where 'foo' was replaced with 'bar'.

How do you run :%s/foo/bar/g without the cursor leaving the original position before issuing this command?

Is there some option I can set in .vimrc file?

解决方案

I just type Ctrl+O after the replace to get back the the previous location.

这篇关于Vim全部替换而无需移动光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆