This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-11
Channels
- # adventofcode (52)
- # announcements (3)
- # aws (2)
- # babashka (36)
- # babashka-sci-dev (4)
- # beginners (69)
- # biff (45)
- # calva (9)
- # cider (3)
- # clara (8)
- # clj-kondo (24)
- # clojure (20)
- # clojure-dev (12)
- # clojure-europe (12)
- # clojurescript (2)
- # conjure (1)
- # emacs (17)
- # lsp (69)
- # malli (12)
- # off-topic (32)
- # polylith (2)
- # re-frame (4)
- # releases (2)
- # scittle (6)
- # shadow-cljs (21)
- # tools-deps (10)
- # vim (11)
- # xtdb (11)
How do people generally delete a file that is open in the current buffer using (neo)vim commands ?
It seems a pain to have to remember the exact path to the file to use :!rm ...
and if I am going to use rm
then I may as well do that in my highly optimised terminal shell. Maybe I am missing something
Reading the neovim docs just got me confused and I havent found a tutorial yet.
According to Stack Overflow it seems the simplest way is :call delete(@%)
although this doesnt delete the buffer, so it looks like it doesnt work. Using :call delete(@%) | bdelete!
seems to be more like what I am after (although this seems to hang my neovim setup) Is there a nicer way? Like a :filedelete command I am missing?
I would like to have a nice key binding to delete a file, something like <leader>fD
Or do you not use (neo)vim commands and use the command line or visual file manager (e.g. nvim-tree)
I open current dir with current file under cursor in netrw
using -
(mapping from vim-vinegar
plugin), then D
to delete file under cursor, then enter
to confirm - 3 keys
> It seems a pain to have to remember the exact path to the file to use :!rm ...
You can do :!rm %
Using :NvimTreeFindFile
highlights the file in the nvim-tree buffer, so d
does delete it, providing a confirmation prompt first. The buffer is also removed too, so that's a nice bonus. This probably fits my workflow the best, thanks @U6T7M9DBR
Using !rm %
is a nice alternative , thanks.
I generally do a !rm %
pretty much the same as if I wanted to run any other shell command on that specific file
@US03ZP2F5 thanks for the tip. I have been using :source %
a lot to reload my vimrc file. It just hit me that % was a way to refer to the file in the current buffer. thanks!
I use NvimTree and I configured it to track the current file. Then I open it and press d
, then y
to confirm.