mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 19:13:46 -05:00
Improved fix for #20
Instead of relying on a /g or /gg flag based on gdefault, I temporarily disable gdefault and set it back to the old value aftwards.
This commit is contained in:
@@ -51,13 +51,13 @@ function! s:SetActive(bool) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||||
let gflag = 'g'
|
let old_gdefault = &gdefault
|
||||||
if &gdefault | let gflag = 'gg' | endif
|
set nogdefault
|
||||||
|
|
||||||
let delim = g:table_mode_delimiter
|
let delim = g:table_mode_delimiter
|
||||||
if a:0 | let delim = a:1 | endif
|
if a:0 | let delim = a:1 | endif
|
||||||
if delim ==# ','
|
if delim ==# ','
|
||||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs,\\ze[^\'\"]*[\'\"]/__COMMA__/" . gflag
|
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs,\\ze[^\'\"]*[\'\"]/__COMMA__/g"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let [cstart, cend] = [tablemode#table#GetCommentStart(), tablemode#table#GetCommentEnd()]
|
let [cstart, cend] = [tablemode#table#GetCommentStart(), tablemode#table#GetCommentEnd()]
|
||||||
@@ -67,11 +67,13 @@ function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
|||||||
|
|
||||||
silent! execute a:line . 's/' . tablemode#table#StartExpr() . '\zs\ze' . match_char_start .
|
silent! execute a:line . 's/' . tablemode#table#StartExpr() . '\zs\ze' . match_char_start .
|
||||||
\ '\|' . delim . '\|' . match_char_end . '\zs\ze' . tablemode#table#EndExpr() . '/' .
|
\ '\|' . delim . '\|' . match_char_end . '\zs\ze' . tablemode#table#EndExpr() . '/' .
|
||||||
\ g:table_mode_separator . '/' . gflag
|
\ g:table_mode_separator . '/g'
|
||||||
|
|
||||||
if delim ==# ','
|
if delim ==# ','
|
||||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs__COMMA__\\ze[^\'\"]*[\'\"]/,/" . gflag
|
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs__COMMA__\\ze[^\'\"]*[\'\"]/,/g"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let &gdefault=old_gdefault
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Tableizeline(line, ...) "{{{2
|
function! s:Tableizeline(line, ...) "{{{2
|
||||||
|
|||||||
Reference in New Issue
Block a user