在Vim中缩进整个文件而不保留当前光标位置 [英] Indenting entire file in Vim without leaving current cursor location

查看:77
本文介绍了在Vim中缩进整个文件而不保留当前光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经知道gg=G可以缩进Vim上的整个文件.但这会使我缩进后转到文件的开头.如何缩进整个文件并将光标保持在同一位置?

I already know that gg=G can indent the entire file on Vim. But this will make me go to the beginning of the file after indent. How can I indent the entire file and maintain the cursor at the same position?

推荐答案

请参见:h ''

这将使您回到开始的那一行的第一个字符:

This will get you back to the first char on the line you start on:

gg=G''

,这将使您回到起始行起始列:

and this will get you back to the starting line and the starting column:

gg=G``

我认为带有反引号的第二个版本是您想要的版本.实际上,我通常只使用双撇号版本,因为很难在键盘上使用反引号.

I assume the second version, with the backtick, is the one you want. In practice I usually just use the double apostrophe version, since the backtick is hard to access on my keyboard.

这篇关于在Vim中缩进整个文件而不保留当前光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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