0

I am trying to mark up some various common SQL keywords, and here is what I have...on one line:

autocmd Syntax * syn match pythonSql       /\v<(SELECT|INSERT INTO|UPDATE|ON DUPLICATE KEY|FROM|WHERE|JOIN|INNER|OUTER|LEFT|RIGHT|ORDER BY|AND|IN|NOT IN|ON|USING|ORDER BY|LIMIT|OFFSET|CONCAT|COALESCE|ALTER TABLE|DISTINCT|OR|AND|IS NULL|NULL|GROUP BY|UNION|ALL|CASE|WHEN|THEN|IF|IFNULL)\ze\s/ containedin=.*String

What would be the correct/most legible way to write this? How can one break up commands onto multiple lines? And how could someone break up a string into multiple units or lines?

2
  • 2
    See :h line-continuation. No special syntax for breaking up strings, except concatenating them and :execute-ing target command.
    – Matt
    May 24, 2020 at 4:53
  • @Matt I see -- how would you suggest writing out the above?
    – David542
    May 24, 2020 at 5:18

1 Answer 1

2

While :source-ing VimScript file there's :h line-continuation support (unless &cpoptions contains C, which is NOT the default).

If the code still looks ugly, try to :execute the concatenated string:

let l:myargs = [
    \ 'arg1',
    \ 'arg2',
    ...
\ ]

execute 'command-name' join(l:myargs) 'more-args'

Sometimes also helps :h printf() and :h string()

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .