Browse Source

testing

master
lolson 9 years ago
parent
commit
b04dd513ea
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      plugin/makecols.vim

+ 13
- 5
plugin/makecols.vim View File

@ -11,32 +11,40 @@ function! s:get_visual_selection()
" Why is this not a built-in Vim script function?! " Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2] let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2] let [lnum2, col2] = getpos("'>")[1:2]
execute lnum1 . "," . lnum2 . "delete"
let lines = getline(lnum1, lnum2) let lines = getline(lnum1, lnum2)
" let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] " let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
" let lines[0] = lines[0][col1 - 1:] " let lines[0] = lines[0][col1 - 1:]
return join(lines, ",")
let selection = join(lines, ",")
return selection
endfunction endfunction
function! s:convert_selection(selection) function! s:convert_selection(selection)
" Remove the current selection
execute lnum1 . "," . lnum2 . "delete"
" Setup some variables
let c = 0 let c = 0
let selection = a:selection let selection = a:selection
let old_selection = split(selection, ",")
let no_of_cols = 6 let no_of_cols = 6
let new_string = "" let new_string = ""
let old_selection = split(selection, ",")
let @z = ""
" Let's print out some info
echom "Old Selection: " echom "Old Selection: "
echom join(old_selection, ", ") echom join(old_selection, ", ")
let @z = ""
" For Loopage Goes here
for i in old_selection for i in old_selection
" start combining
if (c == 0) if (c == 0)
" If first selected line
let new_string = join([new_string, old_selection[i]], "") let new_string = join([new_string, old_selection[i]], "")
else else
if (c % no_of_cols) if (c % no_of_cols)
" If regular column
let new_string = join([new_string, old_selection[i]], "\t") let new_string = join([new_string, old_selection[i]], "\t")
else else
" If end of row
let new_string = join([new_string, old_selection[i]], "\n") let new_string = join([new_string, old_selection[i]], "\n")
endif endif
endif endif

Loading…
Cancel
Save