sh.vim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. " Vim filetype plugin file
  2. " Language: sh
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Dan Sharp
  5. " Last Change: 2022 Sep 07
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let b:did_ftplugin = 1
  10. " Make sure the continuation lines below do not cause problems in
  11. " compatibility mode.
  12. let s:save_cpo = &cpo
  13. set cpo-=C
  14. setlocal comments=:#
  15. setlocal commentstring=#\ %s
  16. setlocal formatoptions-=t formatoptions+=croql
  17. let b:undo_ftplugin = "setl com< cms< fo<"
  18. " Shell: thanks to Johannes Zellner
  19. if exists("loaded_matchit") && !exists("b:match_words")
  20. let b:match_ignorecase = 0
  21. let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line
  22. let b:match_words =
  23. \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' ..
  24. \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' ..
  25. \ s:sol .. 'case\>:' .. s:sol .. 'esac\>'
  26. unlet s:sol
  27. let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
  28. endif
  29. " Change the :browse e filter to primarily show shell-related files.
  30. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  31. let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" ..
  32. \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" ..
  33. \ "Bash Shell Scripts (*.bash)\t*.bash\n" ..
  34. \ "All Files (*.*)\t*.*\n"
  35. let b:undo_ftplugin ..= " | unlet! b:browsefilter"
  36. endif
  37. " Restore the saved compatibility options.
  38. let &cpo = s:save_cpo
  39. unlet s:save_cpo
  40. " vim: nowrap sw=2 sts=2 ts=8 noet: