How to change directory character in NetRW of Vim?
Asked Answered
D

1

6

The default file explorer inside Vim is NetRW. It can be invoked, for example, by using :e .. In its tree view, it prefixes the directory name with pipe characters (|).

For example:

joe/
| Desktop/
| Documents/
| Downloads/

How can I replace the pipe character with something else in the tree display of NetRW?

I have looked at the monster netrw.vim file and cannot seem to find this pipe character in it.

Danner answered 18/9, 2014 at 14:3 Comment(3)
Why would you want to do this?Whitehouse
@IngoKarkat: To beautify the display a bit. I could replace the pipe with some of the fancy Unicode symbols :-)Danner
Instead of modifying the plugin, I'd ask DrChip, its author, for support for such. Alternatively, you can switch to the NERD_Tree plugin; it allows to influence this via a config variable.Whitehouse
Q
3

You didn't look hard enough:

if has("gui_running") && (&enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4')
 let s:treedepthstring= "│ "
else
 let s:treedepthstring= "| "
endif

Line 439 of $VIMRUNTIME/autoload/netrw.vim (in version 151, at least).

Quartering answered 18/9, 2014 at 14:45 Comment(2)
This doesn't actually answer the question of how to change it. I'm not a vim scripts expert, but it looks like the answer is that you can't?Insight
If the question is "can it be done?", then the answer is "yes". If the question is "how can I do it?", then the answer is "get an up-to-date version of Netrw and make whatever change you want in the snippet above". If the question is "is there an option for that", the the answer is "no".Quartering

© 2022 - 2024 — McMap. All rights reserved.