1

I am attempting to use the Ultisnips Vim plugin to replace a word with its first character, transformed to lowercase (anong other things that aren't relevant to the question). For illustration, I wish to write a snippet

snippet 
$1 ${1/ WHAT TO PUT HERE / AND HERE /}
endsnippet

which would output

Word w
user59959
  • 193
  • 1
  • 5

1 Answers1

4

One way to do it:

snippet w
$1 ${1/(.).*/\l$1/}
endsnippet

Please note that the replacement strings use Python regexps and syntax, not VimL.

Another way (cleaner, IMO):

snippet w
$1 `!p snip.rv=t[1][0:1].lower()`
endsnippet
Sato Katsura
  • 3,066
  • 15
  • 21