Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个脚本,它将剪贴板中的文本粘贴到 Vim 的当前缓冲区中,设置新的 textwidth 值、新的文件类型,然后根据这些新设置重新格式化(gggqG 键组合)这个缓冲区。
是否可以将所有这些动作再现为一系列命令?
尝试使用以下命令。您可以将其部分拆分为一个函数,但也可以在 vim 的命令行中使用。
a此示例在当前缓冲区的开头插入寄存器的内容,设置一些选项并格式化整个脚本:
a
:0put a | set textwidth=10 | set filetype=python | normal gggqG<CR>