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?
netrw has a
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)