1

I would like to use two custom snippets whose endings are the same:

snippet ah "\aH for ta marbuta" i
\\aH${0}
endsnippet

snippet iyyah "\iyyah" i
\\iyyah${0}
endsnippet

How can I tell UltiSnips to prioritize iyyah over ah? That is, when I write rūmiyyah then press <TAB>, I want the result to be rūm\iyyah, not rūmiyy\aH. (Currently what happens when I press <TAB> is that NeoVim asks me which of the two snippets I want to use.)

1 Answer 1

1

From :h UltiSnips-basic-syntax, a few paragraphs down,

A line beginning with the keyword 'priority' sets the priority for all snippets defined in the current file after this line. The default priority for a file is always 0. When a snippet should be expanded, UltiSnips will collect all snippet definitions from all sources that match the trigger and keep only the ones with the highest priority. For example, all shipped snippets have a priority < 0, so that user defined snippets always overwrite shipped snippets.

By default, all snippets have priority 0. Therefore, to prioritize iyyah over ah,

priority 1
snippet iyyah "\iyyah" i
\\iyyah${0}
endsnippet
3
  • Will that change the priority of just this snippet or all snippets in the file? Or all snippets after this point in the file? Aug 11, 2022 at 16:09
  • 1
    @AlexRoberts that will change the priority for all snippets after that point. To reset the priority, add a priority 0 after that snippet,
    – husB
    Aug 12, 2022 at 0:38
  • That worked -- thank you! Aug 12, 2022 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.