Ultisnips: Get name of current file in snippet

Created on 6 Nov 2018  路  1Comment  路  Source: SirVer/ultisnips

For expanding out Java classes I want to get the currently-being-edited file's base name.

answered or workaround exists user question

Most helpful comment

Try to use snip.basename in a python interpolation.

As an example, write this snippet in your java.snippets file:

snippet foo ""
`!p snip.rv = snip.basename`
endsnippet

Insert foo in your .java file and press the key to expand the snippet; the result should be the basename of the current file.

gif

For more information, see :h Ultisnips-python.

If you have other usage questions, try to visit https://vi.stackexchange.com/ and tag your question with plugin-ultisnips.

>All comments

Try to use snip.basename in a python interpolation.

As an example, write this snippet in your java.snippets file:

snippet foo ""
`!p snip.rv = snip.basename`
endsnippet

Insert foo in your .java file and press the key to expand the snippet; the result should be the basename of the current file.

gif

For more information, see :h Ultisnips-python.

If you have other usage questions, try to visit https://vi.stackexchange.com/ and tag your question with plugin-ultisnips.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanabel picture vanabel  路  7Comments

LinArcX picture LinArcX  路  3Comments

kirillbobyrev picture kirillbobyrev  路  4Comments

PratikBhusal picture PratikBhusal  路  3Comments

ghost picture ghost  路  8Comments