Function that return visually selected text

I know this question have already been asked everywhere but I’ve tried everything and nothing seem to work fine for me. I’d like to have a function that when is called returns the string value of the text visually selected. Is there a way to make that in lua? Thanks for your time (:

It seem to work, but either the line returned isn’t the one I selected or I have this error bad argument #1 to 'sub' (string expected got nil) (the error is on this line : lines[1] = string.sub(lines[1], s_start[3], -1)).
Thanks for your answer

EDIT: I did some debug and this just had to do with the way I was calling the function. Thank you this works really well! Have a nice day (:

1 Like