csv.vim 511 B

1234567891011121314151617181920212223
  1. " Maintainer: Maxim Kim <habamax@gmail.com>
  2. " Converted from vim9script
  3. " Last Update: 2024-06-18
  4. if !exists("b:csv_delimiter")
  5. " detect delimiter
  6. let s:delimiters = ",;\t|"
  7. let s:max = 0
  8. for s:d in s:delimiters
  9. let s:count = getline(1)->split(s:d)->len() + getline(2)->split(s:d)->len()
  10. if s:count > s:max
  11. let s:max = s:count
  12. let b:csv_delimiter = s:d
  13. endif
  14. endfor
  15. endif
  16. if exists("b:did_ftplugin")
  17. finish
  18. endif
  19. let b:did_ftplugin = 1