如果文件的标题是 "test.cpp",则使 vim 在关闭后删除文件
To make vim delete a file after closing it if its title is "test.cpp"
因为我现在正在玩CP。
我必须尝试各种代码进行测试,但我厌倦了手动删除我创建的每个试用代码。所以我希望 vim 自动化这些东西。如果文件名为 'test.cpp' 并且位于桌面。它应该会自动删除,以便每当我打开 test.cpp 时都会加载一个新文件和我的预定义模板
这听起来像是自动命令的用途:
augroup TestDotCPP
autocmd!
autocmd VimLeavePre /path/to/test.cpp call delete('/path/to/test.cpp')
augroup END
该自动命令告诉 Vim 在您编辑特定文件时退出 Vim 时删除 /path/to/test.cpp
。
参见 :help autocommnad
和 :help delete()
。
因为我现在正在玩CP。 我必须尝试各种代码进行测试,但我厌倦了手动删除我创建的每个试用代码。所以我希望 vim 自动化这些东西。如果文件名为 'test.cpp' 并且位于桌面。它应该会自动删除,以便每当我打开 test.cpp 时都会加载一个新文件和我的预定义模板
这听起来像是自动命令的用途:
augroup TestDotCPP
autocmd!
autocmd VimLeavePre /path/to/test.cpp call delete('/path/to/test.cpp')
augroup END
该自动命令告诉 Vim 在您编辑特定文件时退出 Vim 时删除 /path/to/test.cpp
。
参见 :help autocommnad
和 :help delete()
。