如何查看vim中最后几次击键?

发布于 2024-11-08 07:06:48 字数 481 浏览 0 评论 0原文

有时我在笔记本电脑的小键盘上按了错误的键,并且出现奇怪的导航或编辑(有时这对我来说是新功能)。

虽然我可以撤消编辑(u)或导航(control-o),但我不知道我做错了什么,因此将来很难避免它。不知道刚刚发生了什么也令人沮丧。所以,我希望能够看到我最后几次击键。

有点像 :set showcmd,但显示文字击键,以及(理想情况下)它们的简短历史记录。

我只在 help/google 中找到了命令行和导航历史记录。


澄清一下:我不是在寻找命令行历史记录,而是在寻找击键历史记录。例如,我是否不小心按了 ) 并转到了下一句话?我是否按了 dd 并删除了一行?我猜它类似于击键记录器

命令行历史记录 (:history) 仅显示在 : 提示符下输入的命令。

Sometimes I hit the wrong keys on my laptop's small keyboard, and odd navigation or editing occurs (sometimes a feature that's new to me).

Although I can undo the editing (u) or navigation (control-o), I don't know what I did wrong, so it's difficult to avoid it in future. It's also frustrating to not know what just happened. So, I would like to be able to see my last few keystrokes.

A bit like :set showcmd, but to show the literal keystrokes, and (ideally) a short history of them.

I've only found commandline and navigation history in help/google.


To clarify: I'm not looking for commandline history, but keystroke history. e.g. did I press ) accidentally and go to the next sentence? Did I press dd and delete a line? I guess it's similar to a keystroke logger.

Commandline history (:history) only shows commands entered at the : prompt.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

辞取 2024-11-15 07:06:48

有点旧,但我刚刚在 reddit 上发现了这个:

您可以使用 -w 标志启动 vim 以将所有击键写入文件中。请参见:h -w

vim -w filename

A bit old, but I've just found this on reddit:

You can start vim with the -w flag to write all keystrokes in a file. See :h -w

vim -w filename
梦冥 2024-11-15 07:06:48

据我所知,您可以获得的最接近的是 q 命令,它将您的击键记录到您选择的寄存器中。显然,这必须先进行设置,因为它是为了复杂的重复而设计的,尽管您可能会破解一些东西以在每个打开的文件上开始记录。不过,存在内存使用情况和烦人的“录音”提示的问题。

最直接的方法可能是安装键盘记录软件。我对这些没有任何个人经验,但如果您从值得信赖的来源获得它或自己构建它,将其设置为仅记录到内存而不是磁盘,只有一个大小为句子左右,或者只记录 vim windows。

To my knowledge, the closest you can get is the q command, which records your keystrokes into a register of your choice. Obviously, that has to be set up a priori as it's intended for complex repeats, although you could probably hack something to start recording on every file open. There's the matter of memory usage and that annoying "recording" prompt though.

Probably the most straightforward way would be to install keylogging software. I don't have any personal experience with these, but the security implications are probably mild if you get it from a trustworthy source or build it yourself, set it to only log to memory not a disk, only have a buffer the size of a sentence or so, or only log for vim windows.

笑红尘 2024-11-15 07:06:48

最近我遇到了 Vim 的日志插件,它让我想起了这个问题:

http:// wolever.net/~wolever/wiki/vim-logging

它基本上记录了您所做的一切以供以后分析,它的目的是获取有关命令使用情况的统计数据,但应该可以完美地查找您意外输入的那些神奇命令。

More recently I came across a logging plugin for Vim and it reminded me of this question:

http://wolever.net/~wolever/wiki/vim-logging

It basically records everything you do for later analysis, it was intended for getting statistics about command usage but should work perfectly for finding what those magic commands you accidentally entered were.

樱花坊 2024-11-15 07:06:48

:history 将显示您的命令历史记录 - 这应该可以帮助您发现我们在 vim 中通过错误的击键发现的新功能。

:history will show your command history - that should help you uncover the new features that we all uncover in vim with misplaced keystrokes.

橪书 2024-11-15 07:06:48

Gundo - 可能值得一看,但也许不完全是你的样子看看它会有一点帮助。

它可以让您可视化 Vim 撤消树,这意味着您将能够看到最后发生的编辑。例如,如果您不小心删除了一行或某些此类内容,这将显示在树中,但是,它不会显示您按下的实际击键,也不会显示光标移动等内容。

Gundo - Is probably worth a look, whilst perhaps not exactly what you are looking it will help slightly.

It lets you visualise the Vim undo tree, this means you will be able to see the last edits that happened. For example if you accidentally deleted a line or some such this will show up in the tree, however, it doesn't show you the actual keystrokes that were pushed and will not show things such as cursor movements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文