简体   繁体   English

如何在特殊文件中记录我在 Vim 编辑器中使用的所有命令?

[英]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!”一起使用的脚本文件,这很有用。

  1. Press qx , which causes Vim to start recording your keystrokes.qx ,这将使 Vim 开始记录您的击键。
  2. Press q to finish recording.q完成录音。
  3. Move your cursor to wherever you would like Vim to paste the record it has just made.将光标移动到您希望 Vim 粘贴刚刚创建的记录的任何位置。
  4. Press "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.缓冲区yz等也存在,因此您可以根据需要使用与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.

相关问题 我习惯与控制台命令一起使用的文本编辑器 - What text editor to use in conjunction with console commands that I am used to 如何使用vim命令行从vim编辑器复制所有文本? - How to copy all the text from vim editor using vim command line? 如何使用linux命令删除文件字符串中的特殊字符 - How to remove a special character in a string in a file using linux commands 修改路径文件后,所有基本命令(ls,cd,…以及vi,vim)均不起作用 - all the basic commands (ls, cd, …, as well as vi, vim) not working after modifying the Path file 如何列出Linux目录中的所有文件,其中包含root用户和其他用户使用完整路径使用的基本命令和shell? - How can I list all files in a Linux directory that holds basic commands and shells used by root and other users using a full path? 如何将来自 vim 的 unix 命令与在拆分 window 中打开的所有文件相关联? - How to associate unix commands from vim, with all the files opened in a split window? 在vim编辑器中打开同一文件时,如何列出写入文件的路径下的内容? - How to list the contents under a path written a file while opening the same file in vim editor? 如何将所有Unix用户正在执行的所有命令记录在一个文件中? - How to log all the commands being executed by all Unix users in a file? 如何通过shell脚本执行vim命令 - How to execute the vim commands through shell script 如何在Vim中从终端切换回编辑器? - How to switch from terminal back to editor in vim?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM