Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make % working on "begin" or "end" in a SQL block

Tags:

vim

In TSQL, we are using BEGIN END to embrace a block instead of {}. We can use % to go the beginning or ending of a block if using {}, but I want to go the beginning or ending of a block even if using BEGIN, END, how could that be done?

like image 308
Daniel Wu Avatar asked Mar 23 '23 10:03

Daniel Wu


1 Answers

That's what the shipped matchit plugin is for! :)

:set filetype=sql
:runtime macros/matchit.vim

Afterwards I could use % on begin/end, too.

See :help sql-matchit and :echo b:match_words (after you set the filetype to sql) to get a list of all word pairs % is working on.

Thus, assuming b:match_words woudn't include begin/end by default, you would add a new pair like this:

:let b:match_words .= ',\<begin\>:\<end\>'
like image 64
mhinz Avatar answered Mar 31 '23 15:03

mhinz