Skip to content

Commit

Permalink
Patch wrapping last word (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
SidOfc committed May 18, 2020
1 parent 6ed0ae0 commit 2292894
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions autoload/mkdx.vim
Original file line number Diff line number Diff line change
Expand Up @@ -761,17 +761,23 @@ fun! s:util.WrapSelectionOrWord(...)
call cursor(line('.'), vcol - strlen(start))
return 'unwrap'
else
let s_ch_w = (line[vcol - 2] == ' ' && line[vcol] == ' ')
let mvcol = vcol - 2
let go_bk = line[mvcol] == ' ' || mvcol < 0 ? '' : 'b'
let motion = s_ch_w ? 'l' : 'e'
let cmd = 'normal! ' . go_bk . '"z' . l:count . 'd' . motion
let single_ch_w = (line[vcol - 2] == ' ' && line[vcol] == ' ')
let mvcol = vcol - 2
let go_bk = line[mvcol] == ' ' || mvcol < 0 ? '' : 'b'
let motion = single_ch_w ? 'l' : 'e'
let col_before = col('.')

if !empty(go_bk)
exe 'normal! ' . go_bk
let col_before = col('.')
endif

exe cmd
exe 'normal! "z' . l:count . 'd' . motion

let col_after = col('.')
let @z = start . @z . end

exe 'normal! "z' . ((vcol >= llen) ? 'p' : 'P')
exe 'normal! "z' . ((vcol >= llen || col_before != col_after) ? 'p' : 'P')
call cursor(line('.'), vcol + strlen(start))
endif
endif
Expand Down

0 comments on commit 2292894

Please sign in to comment.