按“主页"在Vim中缩进 [英] Pressing "Home" in Vim on an Indented Line

查看:66
本文介绍了按“主页"在Vim中缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个坏习惯,就是使用"home"键返回到行首.当我最近开始使用vim时,我注意到当我在缩进的行上按下Home键时,它使我回到行的开头.在Notepad ++(我以前使用的编辑器)中,它将使我返回到该行中缩进之后的代码的开头.

I have a bad habit of using the 'home' key to go back to the beginning of a line. As I recently started using vim I noticed that when I press the home key on a lined that is indented, it returns me to the very beginning of the line. In Notepad++ (the editor I used to use) it would return me to the beginning of the code on that line, right after the indent.

是否有某种方法可以在vim中复制此行为?通常,当我按下主屏幕时,它处于插入"模式,通常我可以在其中插入一个变量.

Is there some way to replicate this behavior in vim? Usually, when I'm pressing home it's in the Insert mode for me to (usually) stick a variable there.

我的vimrc中有set smartindent,其中set noautoindent作为提示"页面告诉我要确保禁用自动缩进(尽管最初似乎没有启用它-也许该选项是多余的) )

I have set smartindent in my vimrc, with set noautoindent as a "tips" page told me to make sure to disable autoindent (although it didn't seem to be enabled in the first place - perhaps that option is extraneous.)

推荐答案

在Vim中行的开始"有两种常用的方法:

There are two usual ways to go to the "beginning" of a line in Vim:

  • 0 (零)转到文本的第一列
  • ^ 转到行上的第一个非空白
  • 0 (zero) go to the first column of text
  • ^ go to the first non-whitespace on the line

我发现使用 0 w 通常是我转到一行上第一个非空白字符的最便捷方法,它的键数与 ^ ,并且更易于访问. (当然,如果行上没有前导空格,请不要按 w .)

I find that using 0w is usually the most convenient way for me to go to the first nonblank character on a line, it's the same number of keys as ^ and is easier to reach. (Of course, if there are no leading spaces on the line, don't press w.)

这篇关于按“主页"在Vim中缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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