(开始把别处的帖子挪过来,哈哈这里面认识我的人少,可以写多谢内容进来。
msn不好的是,很可能读我帖子的人都认识,不敢乱说话,哈哈)
msn不好的是,很可能读我帖子的人都认识,不敢乱说话,哈哈)
嗯,这些日子经常做些比较无聊杂乱的事情。
日语也不一定有多大的长进,但是技术上肯定是没有接触到什么重要的东西!
由于都是杂乱的事情,所以用的csv比较多,经常是用vba生成一些csv文件来用。
我找了别人的一些脚本自己修改了一下添加了功能,用在gvim上面,效果还是不错的!
可以一列一列的高亮显示,阅读csv比较容易的看清csv的每一列。
把下面的代码写到一个readcsv.vim文件里面,放到vim的plugin目录下,
在你的vimrc文件里把下面几行加进去。
autocmd BufNewFile,Bufread *.csv call CSVSELECT()
map <F9> :call CSV_HighlightPrevCol()<CR>
map <F10> :call CSV_HighlightNextCol()<CR>
map <F11> :call CSV_goto_field()<CR>
map <F12> :call CSV_SE()<CR>
map <F10> :call CSV_HighlightNextCol()<CR>
map <F11> :call CSV_goto_field()<CR>
map <F12> :call CSV_SE()<CR>
在gvim启动打开csv结尾的文件就可以用了。
F9 快捷键 可以让当前选择的一列向前移动,
F10 向后移动一列
F11 移动到第几列(注意这开始的数字是零行)
F12 提示选择csv文件是以逗号分隔还是tab键分隔
按照提示输入就行,默认是逗号分隔。
"usage: add below line into your .vimrc
"autocmd BufNewFile,Bufread *.csv call CSVSELECT()
function! CSVSELECT()
"autocmd BufNewFile,Bufread *.csv call CSVSELECT()
function! CSVSELECT()
function! CSV_SE(...)
if a:0 == 0
call inputsave()
let b:current_csv_flag = input('comma, or tab? ')
call inputrestore()
else
let b:current_csv_flag = a:1
endif
if a:0 == 0
call inputsave()
let b:current_csv_flag = input('comma, or tab? ')
call inputrestore()
else
let b:current_csv_flag = a:1
endif
if b:current_csv_flag == ','
call CSVSettings()
elseif b:current_csv_flag == 'comma'
call CSVSettings()
else
call CSVTabs()
endif
endfunction
call CSVSettings()
elseif b:current_csv_flag == 'comma'
call CSVSettings()
else
call CSVTabs()
endif
endfunction
function! CSVSettings()
let b:current_csv_col = 0
" inspired by Vim tip #667
function! CSV_Highlight(x)
if b:current_csv_col == 0
match Keyword /^[^,]*,/
else
execute 'match Keyword /^/([^,]*,/)/{'.a:x.'}/zs[^,]*/'
endif
execute 'normal ^'.a:x.'f,'
endfunction
let b:current_csv_col = 0
" inspired by Vim tip #667
function! CSV_Highlight(x)
if b:current_csv_col == 0
match Keyword /^[^,]*,/
else
execute 'match Keyword /^/([^,]*,/)/{'.a:x.'}/zs[^,]*/'
endif
execute 'normal ^'.a:x.'f,'
endfunction
" start by highlighting something, probably the first column
call CSV_Highlight(b:current_csv_col)
call CSV_Highlight(b:current_csv_col)
function! CSV_HighlightNextCol()
let b:current_csv_col = b:current_csv_col + 1
call CSV_Highlight(b:current_csv_col)
endfunction
let b:current_csv_col = b:current_csv_col + 1
call CSV_Highlight(b:current_csv_col)
endfunction
function! CSV_HighlightPrevCol()
if b:current_csv_col > 0
let b:current_csv_col = b:current_csv_col - 1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
if b:current_csv_col > 0
let b:current_csv_col = b:current_csv_col - 1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
function! CSV_goto_field(...)
if a:0 == 0
call inputsave()
let b:current_csv_col = input('Jump to field? ')
call inputrestore()
else
let b:current_csv_col = a:1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
if a:0 == 0
call inputsave()
let b:current_csv_col = input('Jump to field? ')
call inputrestore()
else
let b:current_csv_col = a:1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
endfunction
function! CSVTabs()
let b:current_csv_col = 0
" inspired by Vim tip #667
function! CSV_Highlight(x)
if b:current_csv_col == 0
match Keyword /^[^ ]* /
else
execute 'match Keyword /^/([^ ]* /)/{'.a:x.'}/zs[^ ]*/'
endif
execute 'normal ^'.a:x.'f '
endfunction
let b:current_csv_col = 0
" inspired by Vim tip #667
function! CSV_Highlight(x)
if b:current_csv_col == 0
match Keyword /^[^ ]* /
else
execute 'match Keyword /^/([^ ]* /)/{'.a:x.'}/zs[^ ]*/'
endif
execute 'normal ^'.a:x.'f '
endfunction
" start by highlighting something, probably the first column
call CSV_Highlight(b:current_csv_col)
call CSV_Highlight(b:current_csv_col)
function! CSV_HighlightNextCol()
let b:current_csv_col = b:current_csv_col + 1
call CSV_Highlight(b:current_csv_col)
endfunction
let b:current_csv_col = b:current_csv_col + 1
call CSV_Highlight(b:current_csv_col)
endfunction
function! CSV_HighlightPrevCol()
if b:current_csv_col > 0
let b:current_csv_col = b:current_csv_col - 1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
if b:current_csv_col > 0
let b:current_csv_col = b:current_csv_col - 1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
function! CSV_goto_field(...)
if a:0 == 0
call inputsave()
let b:current_csv_col = input('Jump to field? ')
call inputrestore()
else
let b:current_csv_col = a:1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
endfunction
if a:0 == 0
call inputsave()
let b:current_csv_col = input('Jump to field? ')
call inputrestore()
else
let b:current_csv_col = a:1
endif
call CSV_Highlight(b:current_csv_col)
endfunction
call CSVSettings()
endfunction