Browse Source

testing

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

+ 21
- 13
plugin/makecols.vim View File

@ -7,6 +7,26 @@ function! s:beep()
return "" return ""
endfunction endfunction
function! s:get_visual_selection()
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 lines
" return join(lines, "\n")
endfunction
function! s:replace_selected_text()
execute "normal! d"
let $clipboard = lines
execute "normal! \"*p"
echo "Just tried to replace the selection with the lines."
return ""
endfunction
function! s:makecols() range function! s:makecols() range
let mode = visualmode() let mode = visualmode()
if (mode !=# "V") if (mode !=# "V")
@ -16,21 +36,9 @@ function! s:makecols() range
echo "You are in the right mode" echo "You are in the right mode"
endif endif
echo s:get_visual_selection() echo s:get_visual_selection()
return ""
return s:replace_selected_text()
endfunction endfunction
function! s:get_visual_selection()
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 lines
" return join(lines, "\n")
endfunction
vnoremap <silent> mc :<C-U>call <SID>makecols()<CR> vnoremap <silent> mc :<C-U>call <SID>makecols()<CR>

Loading…
Cancel
Save