How do I configure an ultisnip to override an existing snippet?
Asked Answered
B

1

15

I use rails.vim but would like to override one or two snippets with my own using ultisnips.

I've created the snippets but since they're already defined by rails.vim a menu now appears when triggered. I'd like my snippets to override the existing one to avoid the menu.

Bondsman answered 3/10, 2014 at 0:17 Comment(5)
Are you sure those snippets are defined by rails.vim? The only mention of snippets I see in the code is this line which enables every "rails" snippet UltiSnips will find. Maybe you should remove the default rails snippets from Honza's library?Wareroom
@Wareroom You're right - they're defined in ~/.vim/bundle/snippets.vim/snippets/ruby.snippets. I'd like to selectively disable ones I override. Do you know of an easy way to achieve this? (I'd rather avoid editing/forking snippets.vim if I can help it).Bondsman
No, I have no experience with UltiSnips or even the forked SnipMate but what is the point of a personal configuration is you refuse to personalize it?Wareroom
@Wareroom You're misunderstanding me: I've added my own custom snippets. The problem is when I go to use some of them I'm getting a menu to choose between mine and some others with the same tab trigger. I want to override this behaviour so mine are used by default (ie no menu). I'd rather not edit or fork snippets.vim because I'd like to pull updates without added maintenance. I appreciate your input, but I suspect someone with ultisnips knowledge will be better placed to answer my question.Bondsman
Yeah, or someone who read the documentation, as always.Wareroom
B
20

The solution is to use priority directive. All snippets default to a priority of 0. Therefore, adding this to the top of my custom snippets solved the issue:

# top of custom snippets file
priority 1
Bondsman answered 7/10, 2014 at 22:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.