Created
May 12, 2016 13:24
-
-
Save HeLiBloks/77299deaa6768edc452e907b263b6e9c to your computer and use it in GitHub Desktop.
different vim functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"returns visual selection | |
function! s:get_visual_selection() | |
" Why is this not a built-in Vim script function?! | |
let [lnum1, col1] = getpos("'<")[1:2] | |
let [lnum2, col2] = getpos("'>")[1:2] | |
let lines = getline(lnum1, lnum2) | |
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] | |
let lines[0] = lines[0][col1 - 1:] | |
return join(lines, "\n") | |
endfunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment