vim-auto-tabstop

A Vim plugin for automatically setting tabstop size
git clone https://git.ce9e.org/vim-auto-tabstop.git

commit
7f6b7e52337aadeb9a65a753cd9ec3841135257b
parent
21112389558087ee78434f811a214dd22c91a85a
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2016-11-18 19:23
ignore long string in last column

Diffstat

M README.md 6 +++---
M plugin/fets.vim 2 +-
M test 2 +-

3 files changed, 5 insertions, 5 deletions


diff --git a/README.md b/README.md

@@ -5,14 +5,14 @@ This is mostly useful to align tsv files like this:
    5     5     James\tSmith\t38,313
    6     6     Michael\tSmith\t34,810
    7     7     Robert\tSmith\t34,269
    8    -1     Maria\tGarcia\t32,092
   -1     8     Maria\tGarcia\t32,092 (long string in last column is ignored)
    9     9 
   10    10 With a tabstop of 2 this will look like this:
   11    11 
   12    12     James Smith 38,313
   13    13     Michael Smith 34,810
   14    14     Robert  Smith 34,269
   15    -1     Maria Garcia  32,092
   -1    15     Maria Garcia  32,092 (long string in last column is ignored)
   16    16 
   17    17 Pressing `<c-t>` will automatically set the tabstop to the value required to
   18    18 get proper alignment (in this case 8):
@@ -20,4 +20,4 @@ get proper alignment (in this case 8):
   20    20     James   Smith   38,313
   21    21     Michael Smith   34,810
   22    22     Robert  Smith   34,269
   23    -1     Maria   Garcia  32,092
   -1    23     Maria   Garcia  32,092 (long string in last column is ignored)

diff --git a/plugin/fets.vim b/plugin/fets.vim

@@ -47,7 +47,7 @@ function! CalcTS()
   47    47 	for l in getline(0, "$")
   48    48 		let i = 0
   49    49 
   50    -1 		for item in split(l, '\t')
   -1    50 		for item in split(l, '\t')[:-2]
   51    51 			if i < tab_count
   52    52 				if len(item) > _max
   53    53 					let _max = len(item)

diff --git a/test b/test

@@ -1,4 +1,4 @@
    1     1 James	Smith	38,313
    2     2 Michael	Smith	34,810
    3     3 Robert	Smith	34,269
    4    -1 Maria	Garcia	32,092
   -1     4 Maria	Garcia	32,092 (long string in last column is ignored)