转换记事本++ vim 语法高亮文件(或者有人有 aq/kdb+ vim 语法高亮文件吗?)

发布于 2024-09-28 11:09:51 字数 168 浏览 8 评论 0原文

我有一个 q/kdb+ 语言的语法突出显示文件,我想将其转换为 vim 兼容文件,这样我的 q 代码就不会看起来比平常更难看。

是否有实用程序可自动将 notepad++ xml 语法突出显示文件转换为 vi 版本?我环顾四周,但没有发现任何东西。

或者有人有 vim q 语法高亮文件吗?

I have a syntax highlighting file for the q/kdb+ language and I'd like to convert it to a vim compatible file so my q code won't look any more ugly than usual.

Are there utilities available to automatically convert notepad++ xml syntax highlighting files to vi versions? I had a look around but I couldn't find anything.

Alternatively does anyone have a vim q syntax highlighting file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放赐 2024-10-05 11:09:51

aq/kdb+ vim 语法高亮文件:
https://github.com/simongarland/vim

a q/kdb+ vim syntax highlight files:
https://github.com/simongarland/vim

Smile简单爱 2024-10-05 11:09:51

这两个问题的答案都是“否”(我不知道有任何转换器,也没有 aq 语法高亮文件),但是 Notepad++ 语法高亮 XML 格式看起来非常简单。我手头没有“Q”一本书,但我查看了 网站 并且翻译看起来非常简单。在这种情况下,您可以使用以下命令完成大部分工作:

" Remove all the lines that aren't lists of keywords
" (there doesn't seem to be anything much more complicated
" than that in the definition file)
:g!/<Keywords name=/d
" Convert the lines (fairly poor XML parsing here!)
:%s/\s*<Keywords name="\([^"]\+\)">\([[:alpha:]_ ]\{-}\)<\/Keywords>/syn keyword \1 \2/

这会生成许多看起来像这样的行:

syn keyword Words1 case then do while

您必须调整语法类(本例中为 Words1),使其成为在 Vim 中突出显示的内容(或 syn-将其链接到将在 Vim 中突出显示的内容)。

然后,您可能可以使用正则表达式处理这些符号,但手动处理可能会更容易,因此将:转换

<Keywords name="Operators">- ! " # $ & * , . ; ? @ \ ^ { | } ~ + < = ></Keywords>

为:(

syn match Operators /\<[-!"#
amp;*,.;?@\\^{|}~+<=>]/

这是 \< 来标记单词边界,然后是包含所有符号的字符类 [..])。

然后,您只需

if exists("b:current_syntax")
    finish
endif

在开头添加: 并

let b:current_syntax = "q"

在末尾添加: 。

当然,这并不能帮助您完成全部任务,但希望它能为您提供获得所需语法文件所需的大量信息。可以在以下位置找到大量帮助:

:help syntax

并查看运行时文件夹的语法目录中的示例。

祝你好运!

The answer to both questions is no (I don't know of any converters and I don't have a q syntax highlighting file), but the Notepad++ syntax highlighting XML format looks extremely simple. I don't have the 'Q' one to hand, but I had a look at one of the ones from the website and the translation looks pretty trivial. In that case, you could do most of the work with:

" Remove all the lines that aren't lists of keywords
" (there doesn't seem to be anything much more complicated
" than that in the definition file)
:g!/<Keywords name=/d
" Convert the lines (fairly poor XML parsing here!)
:%s/\s*<Keywords name="\([^"]\+\)">\([[:alpha:]_ ]\{-}\)<\/Keywords>/syn keyword \1 \2/

This generates lots of lines that look like:

syn keyword Words1 case then do while

You'll have to tweak the syntax class (Words1 in this case) to be something that will be highlighted in Vim (or syn-link it to something that will be highlighted in Vim).

You could probably then deal with the symbols with a regexp, but it might be easier to just do them by hand, so convert:

<Keywords name="Operators">- ! " # $ & * , . ; ? @ \ ^ { | } ~ + < = ></Keywords>

into:

syn match Operators /\<[-!"#
amp;*,.;?@\\^{|}~+<=>]/

(this is \< to mark a word boundary, followed by a character class [..] with all the symbols in it).

You would then just need to add:

if exists("b:current_syntax")
    finish
endif

at the start and:

let b:current_syntax = "q"

at the end.

Of course, this doesn't get you all the way, but hopefully it will give you a lot of what you need to get the syntax file that you want. There is plenty of help available in:

:help syntax

and by looking at the examples in the syntax directory of the runtime folder.

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文