From 617b01a5b6aa3cadb25b2ff8639e330cfc6cf3c1 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 11 Nov 2014 02:37:21 +0100 Subject: Update --- ftplugin/csv.vim | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'ftplugin/csv.vim') diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index 9d8df120..19f649cc 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -517,7 +517,13 @@ fu! WColumn(...) "{{{3 " Return on which column the cursor is let _cur = getpos('.') if !exists("b:csv_fixed_width_cols") - let line=getline('.') + if line('.') > 1 && mode('') != 'n' + " in insert mode, get line from above, just in case the current + " line is empty + let line = getline(line('.')-1) + else + let line=getline('.') + endif " move cursor to end of field "call search(b:col, 'ec', line('.')) call search(b:col, 'ec') @@ -2398,6 +2404,9 @@ fu! csv#EvalColumn(nr, func, first, last) range "{{{3 call CheckHeaderLine() let nr = matchstr(a:nr, '^\-\?\d\+') let col = (empty(nr) ? WColumn() : nr) + if col == 0 + let col = 1 + endif " don't take the header line into consideration let start = a:first - 1 + s:csv_fold_headerline let stop = a:last - 1 + s:csv_fold_headerline @@ -2516,8 +2525,18 @@ fu! CSV_CloseBuffer(buffer) "{{{3 augroup! CSV_QuitPre endtry endfu - +fu! CSVSum(col, fmt, first, last) "{{{3 + let first = a:first + let last = a:last + if empty(first) + let first = 1 + endif + if empty(last) + let last = line('$') + endif + return csv#EvalColumn(a:col, 'SumColumn', first, last) +endfu " Initialize Plugin "{{{2 let b:csv_start = exists("b:csv_start") ? b:csv_start : 1 let b:csv_end = exists("b:csv_end") ? b:csv_end : line('$') -- cgit v1.2.3