什么是“取消标签”? (g)Vim 中的序列?
这是我长期以来的烦恼。
(挑剔部分:我更喜欢 4 个空格字符而不是制表符。输入“制表符”比解释要容易得多。当我说“制表符”时,我的意思是“按下制表符键时发生的操作”,即可能更简单地表述为“增加缩进”。)
我在编辑缩进具有一定意义的文档时使用 smartindent。在“哑”Windows 文本编辑器中,我可以按 Shift+Tab 来删除选项卡,或者更恰当地说,减少当前行的缩进级别。我不知道如何在 Vim 的编辑模式下执行此操作; Shift+Tab 似乎与 Tab 的计数相同。
我知道在命令模式 <<
会减少缩进。我想要编辑模式下的等效内容。这些是我迄今为止找到的解决方案以及为什么我不喜欢它们,其中一个可能是答案的关键。
- 使用 Notepad++ 或其他一些愚蠢的编辑器。我已经这样做了几年,但我真的很想念 Vim。
- 退出编辑模式,使用<<,进入编辑模式。这只是将光标置于第 0 列;如果我想要这个,我就不会尝试 smartindent。
- 停止使用智能缩进。我不会经常减少缩进,因为我需要保持相同的缩进级别;这将导致生产力的损失。
- 左箭头键似乎可以将缩进减少一级。我宁愿做一些不用离开主排就能做的事。这是最有前途的选择。
也许我可以设置一个选项?也许我可以将左箭头重新绑定到某个东西? (如果需要重新绑定,请详细解释;我从未深入研究过重新配置 (g)Vim。
This is an annoyance I've had for a long time.
(Nitpicky section: I prefer 4 space characters to tab characters. It's a lot easier to type "tab" instead of explaining that. When I say "tab", I mean "the action that happens when you press the tab key" which is probably more simply stated as "increase indentation".)
I'm using smartindent while editing a document where indentation has some significance. In "dumb" windows text editors I can press Shift+Tab to remove a tab or, more appropriately, decrease the indentation level of the current line. I can't figure out how to do this from edit mode in Vim; Shift+Tab seems to count just the same as Tab.
I know in Command mode <<
will decrease indentation. I want the equivalent in edit mode. These are the solutions I've found so far and why I don't like them, one in particular may be the key to the answer.
- Use Notepad++ or some other dumb editor. I've done this for a couple of years but I really miss Vim.
- Exit edit mode, use <<, enter edit mode. This just puts the cursor at column 0; if I wanted this I wouldn't have tried smartindent.
- Stop using smartindent. I don't decrease indent as often as I need to keep the same indent level; this would be a loss of productivity.
- The left arrow key seems to decrease the indent by one level. I'd rather something I can do without leaving the home row. This is the most promising choice.
Maybe there's an option I can set? Maybe I can rebind left arrow to something? (If it requires rebinding please explain in detail; I've never delved into reconfiguring (g)Vim.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Ctrl+D 备份一个制表位。这实际上将整行移动到左侧一个制表位; Ctrl+T 向右执行相同的操作。
请注意,这些击键仅在插入模式下有效(在命令模式下使用 << 和 >> 相当于命令模式)。
You can use Ctrl+D to back up one tab stop. This actually moves the whole line to the left one tab stop; Ctrl+T does the same thing to the right.
Note that these keystrokes only work in Insert mode (use << and >> for the equivalent in Command mode).