netrw-plugin: Hide files with names starting with dot

1,664 views
Skip to first unread message

Paul

unread,
May 16, 2012, 10:30:05 AM5/16/12
to vim_use
In the netrw plugin, I often sort by time (reversed) because I'm
looking at files that I've recently worked with. However, many of
the shown files are dot files (many being vim swap files). This
represents a cognitive load when I'm trying to breeze through many
files (with a slew of vim windows open, several being netrw plugins
windows).

Is there a way to hide the dot-files in the display by the netrw
plugin?

Paul

unread,
May 16, 2012, 10:35:18 AM5/16/12
to vim_use
And for that matter, is there a way to hide directories (temporarily
that is)? That temporarily qualification also applies to my question
about hiding dot-files.

Paul

unread,
May 16, 2012, 11:03:40 AM5/16/12
to vim_use
Looks like the following browser option variables do the trick:

*g:netrw_liststyle*

Set the default listing style:
= 0: thin listing (one file per line)
= 1: long listing (one file per line with time
stamp information and file size)
= 2: wide listing (multiple files in columns)
= 3: tree style listing


*g:netrw_list_hide*

comma separated pattern list for hiding files
Patterns are regular expressions (see |regexp|)
Example: let g:netrw_list_hide= '.*\.swp$'
default: ""

This hid dot file & directories:
let g:netrw_list_hide= '.*\.swp$,.*/$'

However, these did not show the file details:
let g:netrw_liststyle=1
let g:netrw_liststyle= 1

Thanks if anyone can point out what might be wrong with my use of
g:netrw_liststyle.

Paul

unread,
May 16, 2012, 11:26:37 AM5/16/12
to vim_use
On May 16, 11:03 am, Paul <paul.domas...@gmail.com> wrote:
>
> Looks like the following browser option variables do the trick:
>
> *g:netrw_liststyle*
>
> Set the default listing style:
> = 0: thin listing (one file per line)
> = 1: long listing (one file per line with time
> stamp information and file size)
> = 2: wide listing (multiple files in columns)
> = 3: tree style listing
>
> *g:netrw_list_hide*
>
> comma separated pattern list for hiding files
> Patterns are regular expressions (see |regexp|)
> Example: let g:netrw_list_hide= '.*\.swp$'
> default: ""
>
> This hid dot file & directories:
> let g:netrw_list_hide= '.*\.swp$,.*/$'
>
> However, these did not show the file details:
> let g:netrw_liststyle=1
> let g:netrw_liststyle= 1
>
> Thanks if anyone can point out what might be wrong with my use of
> g:netrw_liststyle.

I found that

let g:netrw_list_hide= '.*\.swp$,.*/$'

doesn't work for long file listings because the filename is followed
by other information. Since the filename is immediately followed by
white space, I tried:

let g:netrw_list_hide= '.*\.swp\_$,.*/\_$'

However, \_$ doesn't seem to get recognized, so I finally ended up
with:

let g:netrw_list_hide= '.*\.swp$,.*\.swp\s,.*/$,.*/\s'

Also, the "a" key cycles through whether to show files conforming to
g:netrw_list_hide.

As well, the "i" key maps to the different list styles.

Fortunately, the settings seem to be remembered between successive
openings of a directory by netrw.

One thing I found not to be remembered is "setl ts=14" (or whatever
number you use to get the file timestamp column closer to the filename
column). Is there a way to have this setting stick?

Ben Fritz

unread,
May 16, 2012, 1:22:07 PM5/16/12
to vim...@googlegroups.com
On Wednesday, May 16, 2012 10:26:37 AM UTC-5, Paul wrote:
>
> One thing I found not to be remembered is "setl ts=14" (or whatever
> number you use to get the file timestamp column closer to the filename
> column). Is there a way to have this setting stick?

I don't have input for your main problem, sorry about that.

But this one I can handle.

netrw sets the 'netrw' filetype on its buffers.

So simply use a FileType autocmd, or a filetype plugin file (in the after directory).

I.e., either create this autocmd:

au FileType netrw setl ts=14

or create file ~/.vim/after/ftplugin/netrw.vim with contents:

setl ts=14

Paul

unread,
May 16, 2012, 3:57:00 PM5/16/12
to vim_use
Ben, thanks for that. Unfortunately, the specific local value for
tabstop depends on the longest filename of interest (not necessarily
the longest filename in the directory. This is set on a per-directory
basis (and may change if the directory contents change). I just need
the local tabstop value to stick to the buffer for a particular
directory. So I need (or rather, want) vim to treat a netrw window in
the same manner as it does other buffers. That way, even if I close
the window, then open it again (for example, using :e Directory/Path),
the ts value stays the same as it was set to last time.

I get the feeling that I'm asking for the impossible, but there have
been occassions in the past in which I have been pleasantly surprised.

Charles E Campbell Jr

unread,
May 18, 2012, 12:29:09 PM5/18/12
to vim...@googlegroups.com
Try

gh

(see :help netrw-gh)

Regards,
Chip Campbell

Paul

unread,
May 18, 2012, 2:03:27 PM5/18/12
to vim_use
On May 18, 12:29 pm, Charles E Campbell Jr <drc...@campbellfamily.biz>
wrote:
> Try
>
> gh
>
> (see :help netrw-gh)

For some reason, this doesn't seem to do anything when I use it.
Though I can read the help and see that it's suppose to do.

The "a" key mapping seems to be working, though for some reason, this
statement in my vimrc file isn't being picked up:

let g:netrw_list_hide= '.*\.swp$,.*\.swp\s,.*/$,.*/\s'

I have manually source the vimrc file.

Charles E Campbell Jr

unread,
May 19, 2012, 11:29:43 PM5/19/12
to vim...@googlegroups.com
Netrw sets g:netrw_maxfilenamelen to 32 by default; you can change
that as you wish (ie. via .vimrc, etc). It is used to set netrw
buffers' local tabstop value. See :help g:netrw_maxfilenamelen .

Regards,
Chip Campbell

Charles Campbell

unread,
May 21, 2012, 10:26:24 AM5/21/12
to vim...@googlegroups.com
Try putting

let g:netrw_list_hide =
'\(^\|\s\s\)\zs\.\S\+,\(^\|\s\s\)ntuser\.\S\+'

in your .vimrc and see if that does what you want. (see :help
g:netrw_list_hide )

Regards,
Chip Campbell

Message has been deleted

Paul

unread,
May 23, 2012, 11:18:26 AM5/23/12
to vim_use
On May 19, 11:29 pm, Charles E Campbell Jr <drc...@campbellfamily.biz>
wrote:
Sorry about that last email, it was posted under another nym (the
wrong one). I erased it from google groups. Here it is again, with
proper identification.

Thanks, but I need to be able to manually change it depending on the
longest filename in the folder being viewed. Then I need the ts value
to stick for that directory.

Paul

unread,
May 23, 2012, 11:37:02 AM5/23/12
to vim_use
On May 21, 10:26 am, Charles Campbell <Charles.E.Campb...@nasa.gov>
wrote:
I already have:

let g:netrw_list_hide= '.*\.swp\*,.*\.swp$,.*\.swp\s,.*/$,.*/\s'

I'm not sure how the above hide expression helps with a variable
tabstop that sticks with each folder. Can you elaborate on the
thinking behind that?

Note that I found that it's easy to get thrown off by the many places
where vimrc can reside. In Windows, there's the location for all
users, then there is the one in each user's home directory. Same with
cygwin on the same PC (cygwin is a unix environment operating within
the Windows environment). I can think that I've defined the proper
g:netrw_... variable in all places, but after much mucking, find that
I haven't.

Charles Campbell

unread,
May 23, 2012, 12:15:21 PM5/23/12
to vim...@googlegroups.com
Paul wrote:
> On May 21, 10:26 am, Charles Campbell<Charles.E.Campb...@nasa.gov>
> wrote:
>
>> <snip>
>> Try putting
>>
>> let g:netrw_list_hide =
>> '\(^\|\s\s\)\zs\.\S\+,\(^\|\s\s\)ntuser\.\S\+'
>>
>> in your .vimrc and see if that does what you want. (see :help
>> g:netrw_list_hide )
>>
> I already have:
>
> let g:netrw_list_hide= '.*\.swp\*,.*\.swp$,.*\.swp\s,.*/$,.*/\s'
>
> I'm not sure how the above hide expression helps with a variable
> tabstop that sticks with each folder. Can you elaborate on the
> thinking behind that?
>

Sorry -- that response got put into the wrong place. It was concerning
how to hide files beginning with "." while using the long liststyle.
> Note that I found that it's easy to get thrown off by the many places
> where vimrc can reside. In Windows, there's the location for all
> users, then there is the one in each user's home directory. Same with
> cygwin on the same PC (cygwin is a unix environment operating within
> the Windows environment). I can think that I've defined the proper
> g:netrw_... variable in all places, but after much mucking, find that
> I haven't.
>
>
Putting
let g:... = something

in the all-users vimrc should set it up for all users, and you should
not need to put it into user-specific directories.

On the other hand, if you as a specific user want to set up a global
variable for yourself as that user, then put it in
that user's user-specifiec vimrc.

Regards,
Chip Campbell

Paul

unread,
May 23, 2012, 12:30:04 PM5/23/12
to vim_use
On May 23, 12:15 pm, Charles Campbell <Charles.E.Campb...@nasa.gov>
wrote:
> Paul wrote:
>> Note that I found that it's easy to get thrown off by the many
>> places where vimrc can reside. In Windows, there's the location
>> for all users, then there is the one in each user's home directory.
>> Same with cygwin on the same PC (cygwin is a unix environment
>> operating within the Windows environment). I can think that I've
>> defined the proper g:netrw_... variable in all places, but after
>> much mucking, find that I haven't.
>
> Putting
> let g:... = something
>
> in the all-users vimrc should set it up for all users, and you
> should not need to put it into user-specific directories.
>
> On the other hand, if you as a specific user want to set up a global
> variable for yourself as that user, then put it in that user's
> user-specifiec vimrc.

Understood...it's just that the two installs of vim look for vimrc at
different places (each has their own "root install" directory). And
of course, I try to maintain separation between user & global stuff,
so I keep an account-specific copy of vimrc, even though it is the
same as the global. In case I ever need to create another account.

Gary Johnson

unread,
May 23, 2012, 2:32:32 PM5/23/12
to vim_use
On 2012-05-23, Paul wrote:

> Understood...it's just that the two installs of vim look for vimrc at
> different places (each has their own "root install" directory). And
> of course, I try to maintain separation between user & global stuff,
> so I keep an account-specific copy of vimrc, even though it is the
> same as the global. In case I ever need to create another account.

Neither the Windows installer nor the Cygwin installer creates a
system vimrc, so you are free to create and manage your own. If you
want consistency among all users and between Windows and Cygwin, I
would recommend putting your Windows system vimrc in Windows'
$VIM\vimrc (e.g., "C:\Program Files\Vim\vimrc") and creating a
Cygwin symlink to it from Cygwin's $VIM/vimrc (/usr/share/vim/vimrc),
e.g.,

$ ln -s /cygdrive/c/Program\ Files/Vim/vimrc /usr/share/vim/vimrc

Then you have only one system vimrc file to manage.

For those settings that need to be different between the two
systems, use the appropriate one of these tests:

if has("win32")
if has("win32unix")
if has("unix")

Regards,
Gary

Paul

unread,
May 24, 2012, 11:39:58 AM5/24/12
to vim_use
On May 23, 2:32 pm, Gary Johnson <garyj...@spocom.com> wrote:
> Neither the Windows installer nor the Cygwin installer creates a
> system vimrc, so you are free to create and manage your own.

That may be true, its been too long for me to remember. But they do
look in different locations for the pan-users vimrc.

> If you want consistency among all users and between Windows and
> Cygwin, I would recommend putting your Windows system vimrc in
> Windows' $VIM\vimrc (e.g., "C:\Program Files\Vim\vimrc") and
> creating a Cygwin symlink to it from Cygwin's $VIM/vimrc
> (/usr/share/vim/vimrc), e.g.,
>
> $ ln -s /cygdrive/c/Program\ Files/Vim/vimrc /usr/share/vim/vimrc
>
> Then you have only one system vimrc file to manage.
>
> For those settings that need to be different between the two
> systems, use the appropriate one of these tests:
>
> if has("win32")
> if has("win32unix")
> if has("unix")

I use the has("...") alot in vimrc. I also used "ln -s" alot in the
past, but I think I fell out of using it in general because the link
isn't recognized sometimes. I don't recall the circumstances, and for
all I know, it may depend on the version of cygwin. However, thanks
for your suggestion. I will reconsider going back to it, at least for
vim.
Reply all
Reply to author
Forward
0 new messages