From e573b3020c032400eed60b649a2cbf55266e6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 30 Jun 2016 16:03:25 +0200 Subject: Add current configurations from old repository --- vim/bundle/tlib_vim/autoload/tlib/selection.vim | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 vim/bundle/tlib_vim/autoload/tlib/selection.vim (limited to 'vim/bundle/tlib_vim/autoload/tlib/selection.vim') diff --git a/vim/bundle/tlib_vim/autoload/tlib/selection.vim b/vim/bundle/tlib_vim/autoload/tlib/selection.vim new file mode 100644 index 0000000..4417157 --- /dev/null +++ b/vim/bundle/tlib_vim/autoload/tlib/selection.vim @@ -0,0 +1,40 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2016-01-03 +" @Revision: 3 + + +" :display: tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') +" mode can be one of: selection, lines, block +function! tlib#selection#GetSelection(mode, ...) range "{{{3 + if a:0 >= 2 + let mbeg = a:1 + let mend = a:2 + else + let mbeg = "'<" + let mend = "'>" + endif + let opmode = a:0 >= 3 ? a:3 : 'selection' + let l0 = line(mbeg) + let l1 = line(mend) + let text = getline(l0, l1) + let c0 = col(mbeg) + let c1 = col(mend) + " TLogVAR mbeg, mend, opmode, l0, l1, c0, c1 + " TLogVAR text[-1] + " TLogVAR len(text[-1]) + if opmode == 'block' + let clen = c1 - c0 + call map(text, 'strpart(v:val, c0, clen)') + elseif opmode == 'selection' + if c1 > 1 + let text[-1] = strpart(text[-1], 0, c1 - (a:mode == 'o' || c1 > len(text[-1]) ? 0 : 1)) + endif + if c0 > 1 + let text[0] = strpart(text[0], c0 - 1) + endif + endif + return text +endf + -- cgit v1.2.3