如何让 Vim 永远不插入转义码
如果我处于插入模式并点击 Cl(这会清除正常模式下的搜索),Vim 会将 ^L 插入到缓冲区中。我从来不想要这种行为。我该如何禁用它?我不想映射每个可能的命令,我只是不想每次出错时都插入垃圾。
If I am in insert mode and hit C-l (which clears my search in normal mode), Vim inserts ^L into the buffer. I never want this behavior. How do I disable it? I don't want to mapi every possible command, I just don't want garbage inserted every time I make a mistake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在插入模式下使用特定的 Ctrl 组合时遇到问题,您可以随时将其关闭:
:imap ^L
这里的 Nop 是“无操作”。如果它让你感到沮丧,我建议你在尝试戒掉这个习惯的同时将其关闭。每当你看到 ^L 并想“天哪,我又这么做了”时,它可能会起到某种强化作用。
话虽如此,在插入模式下,有很多真正有用的 Ctrl 组合,您可以使用它们来执行有用的操作,因此我不建议将它们全部关闭。
Ctrl-L(以及 Ctrl-Z)是非常有用的键,可以重新映射到您认为有用的东西。它们实际上仅在将插入模式设置为默认模式而不是正常模式时使用 - 请参阅
:h insertmode
Ctrl-L 也非常适合重新映射,因为很容易按在主行上并且重新映射它不应该干扰任何事情。
将其用于您认为有用的事情会建立肌肉记忆,并且应该会阻止您意外按下它。
If you're having problems with a particular Ctrl combination in insert mode, you can always turn it off:
:imap ^L <Nop>
Here Nop is "no operation".If it's frustrating you, I'd recommend turning it off while trying stop the habit. It probably acts as some kind of reinforcement every time you see the ^L and think "D'oh I've done that again".
Having said that, in insert mode there are lots of really useful Ctrl combination that you can use to do useful operations with, so I wouldn't recommend turning them all off.
Ctrl-L (and Ctrl-Z for that matter), are really useful keys to remap to something you find useful. They're really only used when you make insert mode the default mode, rather than normal mode - see
:h insertmode
Ctrl-L is also really nice to remap as it's easy to press being on the home row and it remapping it shouldn't interfere with anything.
Using it for something that you find useful will build up muscle memory and should stop you pressing it by accident.
那你为什么不做
一个快乐的小伙子呢? Co 暂时“暂停”插入模式,因此您可以执行“正常模式”命令,而无需实际离开插入模式。
被严重低估了
:wq
So why don't you
and be a happy chappy? C-o temporarily 'suspends' insert mode, so you can do 'normal mode' command without actually leaving insert mode.
Highly underrated
:wq