From fe93144dc341f42feb5da17450d46f6f5809fc7a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 14 Jun 2019 22:44:45 +1200 Subject: Spruce up CSV and TSV Vim filetype scripts --- vim/ftplugin/csv.vim | 6 ++---- vim/ftplugin/tsv.vim | 13 ++----------- vim/indent/csv.vim | 8 ++++++-- vim/indent/tsv.vim | 13 ++----------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/vim/ftplugin/csv.vim b/vim/ftplugin/csv.vim index 162da402..9bd3e86e 100644 --- a/vim/ftplugin/csv.vim +++ b/vim/ftplugin/csv.vim @@ -4,8 +4,6 @@ if exists('b:did_ftplugin') endif let b:did_ftplugin = 1 -" No autoformatting, literal tabs -setlocal noautoindent -setlocal noexpandtab +" No autoformatting setlocal formatoptions= -let b:undo_ftplugin = 'setlocal autoindent< expandtab< formatoptions<' +let b:undo_ftplugin = 'formatoptions<' diff --git a/vim/ftplugin/tsv.vim b/vim/ftplugin/tsv.vim index 162da402..f78da35f 100644 --- a/vim/ftplugin/tsv.vim +++ b/vim/ftplugin/tsv.vim @@ -1,11 +1,2 @@ -" Only do this when not yet done for this buffer -if exists('b:did_ftplugin') - finish -endif -let b:did_ftplugin = 1 - -" No autoformatting, literal tabs -setlocal noautoindent -setlocal noexpandtab -setlocal formatoptions= -let b:undo_ftplugin = 'setlocal autoindent< expandtab< formatoptions<' +" TSVs have the same filetype options as CSVs +runtime! ftplugin/csv.vim diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim index fd3c99de..78bddd33 100644 --- a/vim/indent/csv.vim +++ b/vim/indent/csv.vim @@ -4,8 +4,12 @@ if exists('b:did_indent') endif let b:did_indent = 1 -" Manual indenting and literal tabs for CSVs +" Manual indenting setlocal noautoindent +let b:undo_indent = 'setlocal autoindent<' + +" Literal tabs setlocal noexpandtab setlocal softtabstop=0 -let b:undo_indent = 'setlocal autoindent< expandtab< softtabstop<' +let &shiftwidth = &tabstop +let b:undo_indent = 'setlocal expandtab< softtabstop< shiftwidth<' diff --git a/vim/indent/tsv.vim b/vim/indent/tsv.vim index adbde97d..ae72397c 100644 --- a/vim/indent/tsv.vim +++ b/vim/indent/tsv.vim @@ -1,11 +1,2 @@ -" Only do this when not done yet for this buffer -if exists('b:did_indent') - finish -endif -let b:did_indent = 1 - -" Manual indenting and literal tabs for TSVs -setlocal noautoindent -setlocal noexpandtab -setlocal softtabstop=0 -let b:undo_indent = 'setlocal autoindent< expandtab< softtabstop<' +" TSVs have the same indent options as CSVs +runtime! indent/csv.vim -- cgit v1.2.3