[SOLVED] vim run perl script with word under cursor as argument


is it possible to send the word under the cursor to a perl script by typing a shortcut?

how do i do that?


Above solutions are not safe if word under cursor contains special characters. You should use

nnoremap <F2> :execute "!/path/to/script.pl ".shellescape(expand("<cword>"), 1)<CR>


For the whole line, replace expand("<cword>") with getline('.'). For the filename under cursor use expand("<cfile>").

Answered By – ZyX

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *