obse.vim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. " Vim filetype plugin file
  2. " Language: Oblivion Language (obl)
  3. " Original Creator: Kat <katisntgood@gmail.com>
  4. " Maintainer: Kat <katisntgood@gmail.com>
  5. " Created: 2021 Aug 08
  6. " Last Change: 2022 Nov 13
  7. " 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. let s:cpo_save = &cpo
  12. set cpo&vim
  13. let b:undo_ftplugin = "setl com< cms<"
  14. noremap <script> <buffer> <silent> [[ <nop>
  15. noremap <script> <buffer> <silent> ]] <nop>
  16. noremap <script> <buffer> <silent> [] <nop>
  17. noremap <script> <buffer> <silent> ][ <nop>
  18. setlocal commentstring=;\ %s
  19. setlocal comments=:;
  20. function s:NextSection(type, backwards, visual)
  21. if a:visual
  22. normal! gv
  23. endif
  24. if a:type == 1
  25. let pattern = '\v(\n\n^\S|%^)'
  26. let flags = 'e'
  27. elseif a:type == 2
  28. let pattern = '\v^\S.*'
  29. let flags = ''
  30. endif
  31. if a:backwards
  32. let dir = '?'
  33. else
  34. let dir = '/'
  35. endif
  36. execute 'silent normal! ' . dir . pattern . dir . flags . "\r"
  37. endfunction
  38. noremap <script> <buffer> <silent> ]]
  39. \ :call <SID>NextSection(1, 0, 0)<cr>
  40. noremap <script> <buffer> <silent> [[
  41. \ :call <SID>NextSection(1, 1, 0)<cr>
  42. noremap <script> <buffer> <silent> ][
  43. \ :call <SID>NextSection(2, 0, 0)<cr>
  44. noremap <script> <buffer> <silent> []
  45. \ :call <SID>NextSection(2, 1, 0)<cr>
  46. vnoremap <script> <buffer> <silent> ]]
  47. \ :<c-u>call <SID>NextSection(1, 0, 1)<cr>
  48. vnoremap <script> <buffer> <silent> [[
  49. \ :<c-u>call <SID>NextSection(1, 1, 1)<cr>
  50. vnoremap <script> <buffer> <silent> ][
  51. \ :<c-u>call <SID>NextSection(2, 0, 1)<cr>
  52. vnoremap <script> <buffer> <silent> []
  53. \ :<c-u>call <SID>NextSection(2, 1, 1)<cr>
  54. let &cpo = s:cpo_save
  55. unlet s:cpo_save