[英]How to document all commands that I used in Vim editor in a special file?
I need to document all commands that I used to modify text using Vim editor .我需要记录我用来使用Vim 编辑器修改文本的所有命令。 When I am in the terminal and need to save all my input in a file I usually write:当我在终端中并且需要将所有输入保存在一个文件中时,我通常会这样写:
history > ~/some_file.txt
However, I am not sure how to do it while using vim.但是,我不确定如何在使用 vim 时做到这一点。 Can you tell me?你能告诉我吗?
Any output can be redirected with :redir
.任何输出都可以使用:redir
重定向。 So所以
redir >~/vim.history|silent history|redir END
Will redirect the output of :history
to the file ~/vim.history
.将:history
的输出重定向到文件~/vim.history
。 Here silent
is used to prevent a -- More --
prompt.这里silent
是用来防止出现-- More --
提示的。
You could also put the history into the current buffer with您还可以将历史记录放入当前缓冲区
:put =execute(':history')
Note that Vims history is limited to 50 entries by default (see :help 'history
).请注意,默认情况下 Vims 历史记录限制为 50 个条目(请参阅:help 'history
)。
Use startup option -w
.使用启动选项-w
。 From the docs:从文档:
All the characters that you type are recorded in the file "scriptout", until you exit Vim.您输入的所有字符都记录在“scriptout”文件中,直到您退出 Vim。 This is useful if you want to create a script file to be used with "vim -s" or ":source!".如果你想创建一个与“vim -s”或“:source!”一起使用的脚本文件,这很有用。
qx
, which causes Vim to start recording your keystrokes.按qx
,这将使 Vim 开始记录您的击键。q
to finish recording.按q
完成录音。"xp
to paste the record.按"xp
粘贴记录。 The x
identifies a buffer. x
标识缓冲区。 Buffers y
, z
and so on also exist, so you can use a different letter than x
if you wish.缓冲区y
、 z
等也存在,因此您可以根据需要使用与x
不同的字母。
Nothing requires you to paste the record into the file you were editing when the record was made, incidentally.顺便说一句,没有什么要求您将记录粘贴到您在制作记录时正在编辑的文件中。 To paste into a different file, give the command :tabedit name-of-different-file
, press [Enter], and then press "xp
to paste. (Since :tabedit
opens the second files in another tab, you can then press gt
to toggle between the two if you wish.)要粘贴到不同的文件中,请输入命令:tabedit name-of-different-file
,按 [Enter],然后按"xp
进行粘贴。(因为:tabedit
在另一个选项卡中打开第二个文件,因此您可以按gt
如果您愿意,可以在两者之间切换。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.