DEV Community

Fran C.
Fran C.

Posted on • Originally published at dev.otrobloggeek.com on

2

Move files in vim with netrw

After some time with emacs I'm back to Vim. This time I'm using Neovim to see what it has to offer.

One thing that I found myself trying to do a couple of days ago was to try to move a set of files into a different folder from inside netrw (which is the file explorer for Vim). Renaming each file one by one was not an option, so I digged a bit on the Vim's help to see what could I find.

It turns out netrw has a move comand which you can invoke on a set of selected files by using mm... the problem is that it needs quite some setup for it to work and it took me some time to realize how to do it:

  1. Find the destination folder on netrw and mark it with mt this will set it as the target of the move.
  2. Find the files you want to move and mark each one of them with mf.
  3. Tell netrw that the original file's folder is the current folder with :cd
  4. In netrw use mm in any of the marked files.

That would move the files to where you want. You can check the help in vim itself with :h netrw-mm but it doesn't tell you about the :cd part, which is the one I was missing and was failing with a strange message about not being able to move the files.

Honestly, too hard to be comfortable at all. I also don't think this works with files from different folders.

Neon image

Serverless Postgres in 300ms (❗️)

10 free databases with autoscaling, scale-to-zero, and read replicas. Start building without infrastructure headaches. No credit card needed.

Try for Free →

Top comments (2)

Collapse
 
lesm profile image
Luis Silva

You can use mv command from vim

:!mv path/file new_path/
Collapse
 
nflamel profile image
Fran C.

I know, buy there are cases in which I want to move a list of files which cannot be pattern matched and being able to mark them and move them is useful... Unfortunately Vim doesn't help a lot with that.

Jetbrains image

Is Your CI/CD Server a Prime Target for Attack?

57% of organizations have suffered from a security incident related to DevOps toolchain exposures. It makes sense—CI/CD servers have access to source code, a highly valuable asset. Is yours secure? Check out nine practical tips to protect your CI/CD.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay