netrw has a gh command that toggles dotfile hiding. It is off by default. I would like it to be on by default. How do I do that?

  • 1
    Actually the gh command is what I needed to know, lovely.
    – helvete
    Commented Dec 22, 2022 at 17:06

2 Answers 2


gh works by modifying netrw_list_hide, rather than by toggling a separate flag. It appends or removes the regex \(^\|\s\s\)\zs\.\S\+. As far as I can tell, said regex matches "a dot followed by any number of non-whitespace characters, starting either at the beginning of the string or after two spaces." I'm not sure why the two spaces, but would be interested to know.

Adding it yourself is straightforward enough:

" If you don't have a hide list and just want to use gh's:
let ghregex='\(^\|\s\s\)\zs\.\S\+'
let g:netrw_list_hide=ghregex

" Or, if you already have a usual hide list, append it
let g:netrw_list_hide='yourhidelist'
let g:netrw_list_hide.=',' . ghregex

In both cases vim will then recognize that gh is toggled on, and typing gh will turn it off.

The regex is hardcoded and not available as a variable (unless your make one yourself, as above), so in principle this will break if it changes. That line hasn't been touched in eleven years, though. It's probably pretty safe to rely on.

(credit to this answer for pointing me in the right direction)

  • Works like charm
    – EsmaeelE
    Commented Jan 21 at 7:21

You can try this on your .vimrc:

let g:netrw_list_hide = '^\..*'        " or anything you like
let g:netrw_hide = 1                   " hide by default

help netrw-a can give you more information.


  • This isn't quite what I asked for, but it was close enough for me to figure it out. Upvoted.
    – Andrew
    Commented Jan 23, 2019 at 18:15
  • Here's a one line saving : The documentation says that g:netrw_hide = 1 is the default, so no need for that
    – cassepipe
    Commented May 19, 2022 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.