Search code examples
vimviml

How to put % into variable in vimscript


I'm looking to capture the current class name (in java) using the % char - but in vimscript I want to push this string value into a variable

let objName = % throws an error currently so I'm looking for some help (vimscript newbie)


Solution

  • You are looking for expand().

       let objName = expand('%:t:r')