如何在 Windows 中启用 Nano 的语法高亮?

如何在 Windows 中启用 Nano 的语法高亮?

我非常喜欢 nano 编辑器,但我无法在 Windows 版本中使用语法高亮功能。Windows 中可以有语法高亮功能吗?

答案1

问题是没有人告诉你原生的 Windows API 版本的纳米,要求您在包含语句中使用POSIX语法高亮文件的路径。*.nanorc.nanorc

编辑你的.nanorc文件C:\Users\<username>\.nanorc并确保导入行如下所示:

#include "C:\nano\nanorc\*.nanorc"     # Windows paths does NOT work!
include "/nano/nanorc/*.nanorc"        # This works!

答案2

詹姆斯·巴克斯特 (James Baxter) 选择的答案不正确。

为了nano在 Cygwin 中启用语法高亮,您需要创建,这是加载语法高亮时查找的~/.nanorc文件。nano

您应在此文件中包括include包含语法高亮文件路径的任何语句,这些文件通常位于/usr/share/nano

我的内容~/.nanorc

include /usr/share/nano/asm.nanorc
include /usr/share/nano/autoconf.nanorc
include /usr/share/nano/awk.nanorc
include /usr/share/nano/c.nanorc
include /usr/share/nano/changelog.nanorc
include /usr/share/nano/cmake.nanorc
include /usr/share/nano/css.nanorc
include /usr/share/nano/debian.nanorc
include /usr/share/nano/default.nanorc
include /usr/share/nano/elisp.nanorc
include /usr/share/nano/fortran.nanorc
include /usr/share/nano/gentoo.nanorc
include /usr/share/nano/go.nanorc
include /usr/share/nano/groff.nanorc
include /usr/share/nano/guile.nanorc
include /usr/share/nano/html.nanorc
include /usr/share/nano/java.nanorc
include /usr/share/nano/javascript.nanorc
include /usr/share/nano/json.nanorc
include /usr/share/nano/lua.nanorc
include /usr/share/nano/makefile.nanorc
include /usr/share/nano/man.nanorc
include /usr/share/nano/mgp.nanorc
include /usr/share/nano/mutt.nanorc
include /usr/share/nano/nanorc.nanorc
include /usr/share/nano/nftables.nanorc
include /usr/share/nano/objc.nanorc
include /usr/share/nano/ocaml.nanorc
include /usr/share/nano/patch.nanorc
include /usr/share/nano/perl.nanorc
include /usr/share/nano/php.nanorc
include /usr/share/nano/po.nanorc
include /usr/share/nano/postgresql.nanorc
include /usr/share/nano/pov.nanorc
include /usr/share/nano/python.nanorc
include /usr/share/nano/ruby.nanorc
include /usr/share/nano/rust.nanorc
include /usr/share/nano/sh.nanorc
include /usr/share/nano/spec.nanorc
include /usr/share/nano/tcl.nanorc
include /usr/share/nano/tex.nanorc
include /usr/share/nano/texinfo.nanorc
include /usr/share/nano/xml.nanorc

最简单的方法就是使用一行简单的命令:

ls -1 /usr/share/nano | sed 's@^@include /usr/share/nano/@' > ~/.nanorc

如果你/usr/share/nano还没有包含任何.nanorc文件,只需从 Git 仓库下载

相关内容