Simple image host.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

multiple_cursors.vim 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "===============================================================================
  2. " File: multiple_cursors.vim
  3. " Author: Terry Ma
  4. " Description: Emulate Sublime Text's multi selection feature
  5. " Potential Features:
  6. " - Create a blinking cursor effect? Good place to do it would be instead of
  7. " waiting for user input, cycle through the highlight
  8. " - Integrate with the status line? Maybe show a special multicursor mode?
  9. " - Support mouse? Ctrl/Cmd click to set cursor?
  10. "===============================================================================
  11. let s:save_cpo = &cpo
  12. set cpo&vim
  13. function! s:init_settings(settings)
  14. for [key, value] in items(a:settings)
  15. let sub = ''
  16. if type(value) == 0
  17. let sub = '%d'
  18. elseif type(value) == 1
  19. let sub = '"%s"'
  20. endif
  21. let fmt = printf("let g:multi_cursor_%%s=get(g:, 'multi_cursor_%%s', %s)",
  22. \ sub)
  23. exec printf(fmt, key, key, value)
  24. endfor
  25. endfunction
  26. " Settings
  27. let s:settings = {
  28. \ 'exit_from_visual_mode': 1,
  29. \ 'exit_from_insert_mode': 1,
  30. \ 'use_default_mapping': 1,
  31. \ 'debug_latency': 0,
  32. \ }
  33. let s:settings_if_default = {
  34. \ 'quit_key': '<Esc>',
  35. \ 'next_key': '<C-n>',
  36. \ 'prev_key': '<C-p>',
  37. \ 'skip_key': '<C-x>',
  38. \ }
  39. call s:init_settings(s:settings)
  40. if g:multi_cursor_use_default_mapping
  41. call s:init_settings(s:settings_if_default)
  42. endif
  43. if !exists('g:multi_cursor_start_key') && exists('g:multi_cursor_next_key')
  44. let g:multi_cursor_start_key = g:multi_cursor_next_key
  45. endif
  46. " External mappings
  47. if exists('g:multi_cursor_start_key')
  48. exec 'nnoremap <silent> '.g:multi_cursor_start_key.
  49. \' :call multiple_cursors#new("n")<CR>'
  50. exec 'xnoremap <silent> '.g:multi_cursor_start_key.
  51. \' :<C-u>call multiple_cursors#new("v")<CR>'
  52. endif
  53. " Commands
  54. command! -nargs=1 -range=% MultipleCursorsFind
  55. \ call multiple_cursors#find(<line1>, <line2>, <q-args>)
  56. let &cpo = s:save_cpo
  57. unlet s:save_cpo