Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.

Highlight file names with non-printable characters like \n or ANSI escape codes

0 votes
asked Feb 23 in vifm by aleksejrs
edited Feb 23 by aleksejrs

I am trying to highlight potentially dangerous or inconvenient file names.

  • highlight /^-/ cterm=underline
  • highlight /[\|&]/ cterm=underline

But how do I match those with a space at the beginning/end; "\r", "\n" or a tab (http://git.net/ml/version-control.monotone.devel/2003-11/msg00045.html), or with the ones mentioned in http://seclists.org/fulldisclosure/2003/Feb/att-341/Termulation.txt ?

1 Answer

+1 vote
answered Feb 24 by xaizek
selected Feb 27 by aleksejrs
 
Best answer

For spaces (includes tabs) that would be \s, some others can be matched with character classes (e.g. [[:cntrl:]]). Extraction of the first parameter of :highlight should be improved to allow space characters. I noticed this before, but couldn't think of a case where it would matter.

And also \x sequence might need to be added to allow specifying arbitrary characters via :execute, because regular expressions don't provide all ASCII table.

commented Feb 25 by aleksejrs
edited Feb 25 by aleksejrs
For spaces (includes tabs) that would be \s,

Works. Thanks.

commented Feb 25 by aleksejrs
[[:cntrl:]]

In Vim, [:cntrl:] can be used inside [] together with other characters.

commented Feb 25 by xaizek

In Vim, [:cntrl:] can be used inside [] together with other characters.

Yeah, seems to work the same way in libregex and thus in vifm.

commented Feb 26 by aleksejrs
Yeah, seems to work the same way in libregex and thus in vifm.

I think when I tried it, it considered it a list of at least "c, n, t, r, l".

commented Feb 26 by xaizek

/[f[:cntrl:]] works fine for example.

commented Feb 27 by aleksejrs

I probably became confused because I couldn't find a way to create a file with a \n. Bell (\07) and backspace work just fine.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here won't be considered as spam, but this is not a perfect place for it.
...