Vim obtain string between visual selection range with Python
Here is some text
here is line two of text
I visually select from is to is in Vim: (brackets represent the visual
selection [ ])
Here [is some text
here is] line two of text
Using Python, I can obtain the range tuples of the selection:
function! getRange()
python << EOF
import vim
buf = vim.current.buffer # the buffer
start = buf.mark('<') # start selection tuple: (1,5)
end = buf.mark('>') # end selection tuple: (2,7)
EOF
endfunction
I source this file: :so %, select the text visually, run :<,'>call
getRange() and
now that I have (1,5) and (2,7). In Python, how can I compile the string
that is the following:
is some text\nhere is
No comments:
Post a Comment