0

Whenever I browse with the netrw 'Explore' command in linux, the directories that I browse through get their modified timestamps changed to when I last changed to that directory.

Is there a way to prevent it from updating the timestamps, since I haven't modified a file inside the directory (similar to how using ls to list and cd to change directories doesn't modify the timestamps of the directory)?

Russ Thils
  • 130
  • 1
  • 9
  • Can you describe your workflow more precisely? – romainl Apr 21 '22 at 13:24
  • While I'm looking for a different file to open using the ":Explore" command and navigating through different directories, Netrw is changing the "modification" timestamps (like given with the 'stats' command or shown by default with 'ls') of the directories that I browse through while trying to find the next file I want to open. This makes it seem like there were either new files or subfolders created or deleted in that directory, when I was just perhaps searching for a file to open and read. – Russ Thils Apr 21 '22 at 20:56

1 Answers1

1

I don't usually have that problem but I was able to replicate it by disabling my config. After a bit of experimentation, I tracked it down to swap files. set noswapfile is what prevents that behaviour in my setup so it should provide a quick solution to your problem.

But, if you want to keep the safety provided by that functionality, you can tell Vim to store swap files in a specific place with the :help 'directory' option.

Note that the Netrw documentation, as of v171, claims that it doesn't create swap files:

*g:netrw_use_noswf*     netrw normally avoids writing swapfiles
                        for browser buffers.  [...]

So it looks like a bug to me, that you should probably consider reporting.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • I failed to mention that I am using an old version of Vim b/c my admins are using RHEL, which comes packaged with vim from like 10 years ago. They refuse to deviate from the official repo to upgrade Vim, which means I'm stuck using Vim 7.4 from 2013. Looking in the plugin folder at the netrwPlugin.vim file, I appear to have v149. Only the 'set noswapfile' option appears to work for me. It would be nice if I had a way to trigger this each time netrw :Explore command is run. – Russ Thils Apr 28 '22 at 07:41