aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-30 14:44:15 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-30 14:44:15 +1300
commit2ec6966a06ea4fa55f8a0fcf68e08a6e0c60332a (patch)
tree3e61728d8f982e37343a5498e49f459914ec30f2
parent71acc00c5b688cc42e3d13881d1c6c9436335066 (diff)
downloaddotfiles-2ec6966a06ea4fa55f8a0fcf68e08a6e0c60332a.tar.gz
dotfiles-2ec6966a06ea4fa55f8a0fcf68e08a6e0c60332a.zip
Add detection, tweak indent/whitespace for CSV/TSV
Vim does not seem to have any built-in detection or settings for CSV or TSV files, so I've added a couple here, based on filename patterns matching the .csv and .tsv extensions. If either of these types are detected, the 'autoindent' and 'expandtab' options are both switched off, as they're undesirable, especially in TSVs where a literal tab is almost certainly what's intended. Ideally, these same two setting would apply to any filetype not otherwise categorisable, but I can't figure out a way to do that safely yet; there was an attempt made in d3d998c.
-rw-r--r--vim/ftdetect/csv.vim7
-rw-r--r--vim/ftdetect/tsv.vim7
-rw-r--r--vim/ftplugin/csv.vim3
-rw-r--r--vim/ftplugin/tsv.vim3
4 files changed, 20 insertions, 0 deletions
diff --git a/vim/ftdetect/csv.vim b/vim/ftdetect/csv.vim
new file mode 100644
index 00000000..4a2d082f
--- /dev/null
+++ b/vim/ftdetect/csv.vim
@@ -0,0 +1,7 @@
+" Add automatic commands to detect CSV files
+augroup dfcsv
+ autocmd!
+ autocmd BufNewFile,BufRead
+ \ *.csv
+ \ setfiletype csv
+augroup END
diff --git a/vim/ftdetect/tsv.vim b/vim/ftdetect/tsv.vim
new file mode 100644
index 00000000..7cfaf1b8
--- /dev/null
+++ b/vim/ftdetect/tsv.vim
@@ -0,0 +1,7 @@
+" Add automatic commands to detect TSV files
+augroup dftsv
+ autocmd!
+ autocmd BufNewFile,BufRead
+ \ *.tsv
+ \ setfiletype tsv
+augroup END
diff --git a/vim/ftplugin/csv.vim b/vim/ftplugin/csv.vim
new file mode 100644
index 00000000..3d78df97
--- /dev/null
+++ b/vim/ftplugin/csv.vim
@@ -0,0 +1,3 @@
+" Manual indenting and literal tabs for CSVs
+setlocal noautoindent
+setlocal noexpandtab
diff --git a/vim/ftplugin/tsv.vim b/vim/ftplugin/tsv.vim
new file mode 100644
index 00000000..53841357
--- /dev/null
+++ b/vim/ftplugin/tsv.vim
@@ -0,0 +1,3 @@
+" Manual indenting and literal tabs for TSVs
+setlocal noautoindent
+setlocal noexpandtab