Browse Source

testing

master
lolson 9 years ago
parent
commit
7c5e345796
1 changed files with 17 additions and 14 deletions
  1. +17
    -14
      plugin/makecols.vim

+ 17
- 14
plugin/makecols.vim View File

@ -8,40 +8,42 @@ function! s:beep()
endfunction
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 no_of_lines = lnum2 - lnum1
let lines = getline(lnum1, lnum2)
execute lnum1 . "," . lnum2 . "delete"
" let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
" let lines[0] = lines[0][col1 - 1:]
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
function! s:convert_selection(selection)
let c = 0
let no_of_cols = 6
let new_string = ""
let old_string = split(&selection, "\n")
echom "Old String: "
echom &selection
echom join(old_string, ", ")
let old_selection = split(selection, "\n")
echom "Old Selection: "
echom join(old_selection, ", ")
let @z = ""
for i in lines
for i in old_selection
" start combining
if (c == 0)
let new_string = join([new_string, lines[i]], "")
let new_string = join([new_string, old_selection[i]], "")
else
if (c % no_of_cols)
let new_string = join([new_string, lines[i]], "\t")
let new_string = join([new_string, old_selection[i]], "\t")
else
let new_string = join([new_string, lines[i]], "\n")
let new_string = join([new_string, old_selection[i]], "\n")
endif
endif
let c += 1
endfor
let @z = join([new_string, ""], "\n")
return lines
return old_selection
endfunction
function! s:replace_selected_text()
@ -60,7 +62,8 @@ function! s:makecols() range
else
echo "You are in the right mode"
endif
echo s:get_visual_selection()
let selection = s:get_visual_selection()
s:convert_selection(selection)
return s:replace_selected_text()
endfunction

Loading…
Cancel
Save