I need to use the less command
with the syntax highlighting of the vim command for python
, C
, bash
and other languages.
How do I apply syntax highlighting colors according to vim
colors for less command
?
bashlesssyntax highlightingvivim
I need to use the less command
with the syntax highlighting of the vim command for python
, C
, bash
and other languages.
How do I apply syntax highlighting colors according to vim
colors for less command
?
Best Answer
Syntax highlighting of
less
, works just fine on most *nix systems.On Fedora/RedHat based distros use
/usr/bin/src-hilite-lesspipe.sh
instead.Even on Cygwin you can do it with the minor adjustment of the shell script path and installing with
apt-cyg
instead ofapt
.However, using this drastically slows down browsing of large files. I suggest to use
alias
in such a way to only implement theLESSOPEN
export above when needed, like this:where the
-M
flag is convenient to also show filename and line number.Also remember to copy the script into your bin path:
UPDATE: 2019-07-24
Apparently, on more recent Cygwin installs, you have the following files in your path:
So now you also need to execute the
source-highlight-settings.exe
that will add the configuration file:$HOME/.source-highlight/source-highlight.conf
.