Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call vim function with current word

Tags:

vim

suppose I have a line like this: hello foo bar

and my cursor is on foo. I want to map a key that will call a function with foo without me having to first select it visually. How would I do this in vim?

like image 210
Vlad the Impala Avatar asked Oct 28 '25 00:10

Vlad the Impala


1 Answers

you are looking for function expand(expression)

here your expression would be '<cword>'

If you love to put it as function argument, you could :yourFunction(expand('<cword>'))

:h expand( for more details.

like image 174
Kent Avatar answered Oct 29 '25 17:10

Kent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!