makecols.vim: converting lists to columns made simple
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
855 B

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. " makecols.vim - Makecolumns
  2. " Author: Levi Olson <http://leviolson.com/>
  3. " Version: 1.0
  4. function! s:beep()
  5. exe "norm! \<Esc>"
  6. return ""
  7. endfunction
  8. function! s:makecols(mode) range
  9. if (mode != "V")
  10. echo "You must be in linewise visual mode"
  11. return s:beep()
  12. else
  13. echo "You are in the right mode"
  14. endif
  15. echo s:get_visual_selection()
  16. return s:beep()
  17. endfunction
  18. function! s:get_visual_selection()
  19. let [lnum1, col1] = getpos("'<")[1:2]
  20. let [lnum2, col2] = getpos("'>")[1:2]
  21. let lines = getline(lnum1, lnum2)
  22. let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
  23. let lines[0] = lines[0][col1 - 1:]
  24. return lines
  25. " return join(lines, "\n")
  26. endfunction
  27. vnoremap <silent> mc :<C-U>call <SID>makecols(visualmode())<CR>
  28. " vim:set ft=vim sw=4 sts=4 et: