英文:
How to map `df` in vim to delete the file under cursor
问题
df
在 vim 中有任何原始(默认)功能吗?- 如何将
df
映射到删除光标下的文件
?
英文:
I know gf
opens the file under cursor, which is so nice. But I want delete the file under cursor. Here are two questions.
- Does
df
have any original(default) function in vim? - How to map
df
todelete the file under cursor
?
答案1
得分: 4
绑定按键盲目删除文件是危险的,应该避免。另一方面,交互式地输入这样的命令并不难:
:!rm <ctrl-r><ctrl-f><enter>
因此,只需大约八次按键即可安全执行。
英文:
Binding keys to blindly delete file is dangerous and should be avoided. On the other hand, it is not so hard to type such command interactively:
:!rm <ctrl-r><ctrl-f><enter>
So it takes only about eight key hits to do it safely.
答案2
得分: 1
我想删除Markdown的图像文件。
这是我的解决方案:
noremap df :call system("rm -f ".expand("<cfile>"))<cr>
当光标位于斜杠上时,我按下 df
,但什么都没有被删除。
英文:
I want delete the image file of markdown.
well, here is my solution
noremap df :call system("rm -f ".expand("<cfile>"))<cr>
I press df
when the cursor is on a slash, and nothing is deleted.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论