我想突出顯示SQL查詢裏面的python三引號字符串在Vim中。使用這種question我有一個pysql.vim
文件,其中包含:vim:higlight SQL裏面的python三引號字符串
if exists('b:current_syntax')
finish
endif
" Load Python syntax at the top level
runtime! syntax/python.vim
unlet b:current_syntax
" Load SQL syntax
syn include @SQL syntax/sql.vim
syntax region sqlSnippet start=/\zs\v(SELECT|FROM|AND|WHERE|OR|ON|GROUP BY|ORDER BY)/ end=/\ze'''/ [email protected] containedin=pythonString
let b:current_syntax = 'pysql'
然而,當我在下面foo.py
文件運行set syntax=pysql
之前
def get_first_events_after_install(application_id, os, event_id,
year_start, month_start, day_start,
year_end, month_end, day_end,
perform=False):
query = \
'''SELECT event_id, counter, name FROM
(
-- This selects event_ids and counts number of occurrences for a
-- specific in a specific time frame
SELECT event_id, COUNT(1) as counter FROM fault.all_events_monthly
WHERE month_partition
BETWEEN '201511' AND '201601'
AND app_partition IN (434)
AND ref_type_partition IN ('apple_ifa')
GROUP by event_id
) t_counter
INNER JOIN
(
-- This selects events names and along event_id
SELECT id, name from mysql.ruby.events
) t_name
ON t_counter.event_id = t_name.id
ORDER BY counter DESC'''.\
format(month_part=month_partitions, os_part=os_partitions,
ys=year_start, ms=month_start, ds=day_start,
ye=year_end, me=month_end, de=day_end, app_id=application_id,
ev_id=event_id)
代碼後串查詢也突出顯示爲SQL(你可以在下圖中看到這個)。所以我的問題是:我如何在三重(或三重雙)引號字符串中強調SQL代碼?提前致謝。
你的機會得到一個答案可能是在[VI和Vim堆棧交易所(http://vi.stackexchange.com/)更好。 – DreyFax