Vim:移动文件?
目前,如果我正在编辑一个文件并且决定要重命名它,我会使用:
:!mv % new.py :new new.py :bd
要重命名该文件,打开新文件,然后删除旧缓冲区。
有没有一种更简单的方法来重命名文件而不留下旧缓冲区?
(我意识到我也可以使用 :sav
,但随后我需要 :bp
几次才能找到以前的缓冲区,:bd
> 它,然后 :bn
返回到新缓冲区)
Currently if I'm editing a file and I decide that I want to rename it, I use:
:!mv % new.py :new new.py :bd
To rename the file, open the new file, then delete the old buffer.
Is there a simpler way to rename a file without leaving the old buffers hanging around?
(I realize that I could also use :sav
, but then I would need to :bp
a few times to find the previous buffer, :bd
it, then :bn
back to the new buffer)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想您可能正在寻找这个插件。
这是一个小插件,可以执行 :saveas 并删除旧文件。
I think you may be looking for this plugin.
It is a little plugin that does :saveas and removes the old file.
我认为添加插件比您正在寻找的要复杂得多。您可以使用函数将此功能绑定到新命令。
将其添加到您的 .vimrc 后,您可以通过执行以下操作来调用它
I think adding a plugin is much more complicated than what you're looking for. You could use a function to bind this functionality to a new command.
After adding this to your .vimrc, you can then call this by doing
您还可以在 vim 资源管理器中重命名文件 移动到要重命名的文件并按:
所以那就是:
:E
j
或搜索文件模式/
R
(回车)。键入的内容是否较短取决于目录中的文件数量。
vi.stackexchange 上的这个答案 建议使用 tpope/vim-eunuch 插件。
You can also rename a file within the vim explorer move to the file you want to rename and press:
So that's:
:E
j
or search file pattern/
R
<CR>
(enter).Whether this is shorter to type or not will depend on the number of files in your directory.
This answer on vi.stackexchange suggests using
:Move
from the tpope/vim-eunuch plugin.