[leglug-users] working with csv files in vim
Naim Abu Darwish
naim.abu.darwish at gmail.com
Fri Jul 6 09:42:16 EDT 2007
hello, im working with some CSV files from vim, i found this script to enable me to select columns.
I placed in /usr/share/vim/vimfiles/plugin/csved.vim , where it will be automatically loaded everytime i start vim, like other plugins. Problem is, its executing before i do :Csv 4, or whatever,it modifies the file, and i get the following::
newt at localhost ~/Desktop/Spark $ vim ../foo.vim
"../foo.vim" "../foo.vim" [converted] 909L, 31516C
6 substitutions on 6 lines
Error detected while processing /usr/share/vim/vimfiles/plugin/csved.vim:
line 13:
E116: Invalid arguments for function CSVH
Press ENTER or type command to continue
the script below, ::
" columnise a csv file for display only as may crop wide columns
:let width = 20
:let fill=' ' | while strlen(fill) < width | let fill=fill.fill | endwhile
:%s/\([^;]*\);\=/\=strpart(submatch(1).fill, 0, width)/ge
:%s/\s\+$//ge
" Highlight a particular csv column (put in .vimrc)
function! CSVH(x)
execute 'match Keyword /^\([^,]*,\)\{'.a:x.'}\zs[^,]*/'
execute 'normal ^'.a:x.'f,'
endfunction
command! -nargs=1 Csv :call CSVH(<args>)
" call with
:Csv 5 : highlight fifth column
Any suggestions ?
--
Naim
More information about the leglug-users
mailing list