2010-10-20 121 views

回答

4

回答這兩個問題是沒有(我不知道任何轉換器,我沒有A Q語法高亮文件),但記事本++語法高亮XML格式看起來非常簡單。我沒有'Q'手,但我看過website中的一個,翻譯看起來很瑣碎。在這種情況下,你可以做最有工作:

" 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中突出顯示的內容(或者將其同步到Vim中將突出顯示的內容)。

你也許可以再處理與一個正則表達式的符號,但它可能是更容易只是用手工做出來,所以轉換:

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

到:

syn match Operators /\<[-!"#$&*,.;[email protected]\\^{|}~+<=>]/ 

(這是\<用於標記一個字邊界,後跟一個字符類[..]及其中的所有符號)。

你會那麼只需要添加:

if exists("b:current_syntax") 
    finish 
endif 

開始和:

let b:current_syntax = "q" 

末。

當然,這並不讓你一路走好,但希望它會給你很多你需要得到你想要的語法文件的內容。有很多的幫助,提供:

:help syntax 

,並通過查看該文件夾中運行時的語法目錄的例子。

祝你好運!

+0

感謝您的提示!這應該使製作vim文件的過程更容易,它看起來並不複雜。我只是懶惰。 – 2010-10-20 16:12:13