I have a command:
command! -nargs=1 TmuxSession !tmux.session "<args>"
and I want to run it in visual mode so that selected text will be passed as argument.
By selected text I mean selected in visual mode in vim.
How can I achieve that?
I tried running
command -nargs=1 -range -register TmuxSession !tmux.session "<args>"
but it keeps saying
E471: Argument required
I know about using
<C-r>" to paste an argument and that is how I use the upper command at the moment, but I don't want to copy selection and paste it every time to the command, because this can be done faster using range.
Following solution does not work:
function! PrintRange() range echo getline(a:firstline, a:lastline) endfunction command! -range PassRange <line1>,<line2>call PrintRange()
because when I want to select second and third word from line containing
one two three - I get the whole line (obviously).
I need to pass only the selected part of the text.