vim:查找最近使用的快捷方式的历史记录 [英] vim: Find history of recently used shortcuts

查看:185
本文介绍了vim:查找最近使用的快捷方式的历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的插件,我的映射或这两者的组合在vim上引起了一些问题.特别是,当我按下特定的组合键时,会发生以下情况:

A plugin that I am using, my mappings, or a combination of those two are causing some issues on vim. In particular, when I press a particular combination of keys the following happens:

  • 当前行中的第一个数字减少
  • 它跳到另一行

问题是我不知道我所按的组合是谁.我无法复制它.我是saving-the-buffers-constantly-freak,所以当我空转"(不在vim上写任何东西)时,我的手指可能会非自愿地进入/退出编辑模式,:wazz,也许还有其他几个,非常快.我必须在这里混合一些导致此问题的快捷方式. 您可能会说停止做您想做的事",但我无能为力.就像一个问题.无法控制.但是,仍然有一条捷径可以执行我不想做的事情,并且无法在我的vim配置中复制或找到它.

The problem is that I don't know who the combination that I am pressing is. I cannot reproduce it. I am a saving-the-buffers-constantly-freak, so when I am "idling" (don't write anything on vim) my fingers involuntary maybe enter/exit edit mode, :wa, zz, maybe a few others, quite fast. I must be mixing some shortcuts here which are causing this issue. You might say "stop doing what you do" but I cannot help it. It's like a problem. Can't control that. But still, there is a shortcut somewhere that it's doing stuff that I don't want to, and I cannot reproduce it or find it in my vim configuration.

顺便说一句,我已经在.vimrc中设置了map <C-a> <Nop>,因此默认的自动增量行为被禁用. (请参见此处的上一个问题)

BTW I have set map <C-a> <Nop> in my .vimrc, so default behavior of auto-increment is disabled. (see a previous question of mine here)

如何查看已使用的历史记录快捷方式? q:不给我这样的信息.

How can I see the history shortcuts that have been used? q: Doesn't give me such information.

推荐答案

我在Vim中不知道如何检索已按下键的历史记录.

I don't know any way in Vim to retrieve the history of the keys having been pressed.

作为替代方案,您可以使用操作系统的功能来做到这一点.

As an alternative, you can use your OS abilities in order to do it.

如果您使用的是Linux系统,则可以轻松记录关键事件.尝试在后台运行这个小bash脚本,它将完成这项工作(未经充分测试,可能需要一些修复);当然,会记录所有所有事件,甚至包括那些在使用Vim时未发生的事件:

If you're on a Linux system, you can log key events quite easily; try to run in background this little bash script, it will do the job (not well tested, it may need some fixes); of course, all events will be recorded, even those which didn't occur while working with Vim:

#!/bin/bash

xinput list |
grep -Po 'id=\K\d+(?=.*slave\s*keyboard)' |
xargs -P0 -n1 xinput test |
awk '
    BEGIN { while (("xmodmap -pke" | getline) > 0) k[$2]=$4 }
    /^key press/ {
        cmd = "date +%H:%M:%S"; cmd | getline date; close(cmd)
        printf("%s [ %s ]\n", date, k[$NF])
    }
' |
tee /tmp/keys.log  # <-- pressed keys will be logged here

这篇关于vim:查找最近使用的快捷方式的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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