Skip to content

Instantly share code, notes, and snippets.

@gimKondo
Created December 16, 2013 16:34
Show Gist options
  • Save gimKondo/7989969 to your computer and use it in GitHub Desktop.
Save gimKondo/7989969 to your computer and use it in GitHub Desktop.
substitute text that selected on visual-mode without overriding register bug: multibyte charactor on line-end cannot be judged well
function! Put_text_without_override_register()
let line_len = strlen(getline('.'))
execute "normal! `>"
let col_loc = col('.')
execute 'normal! gv"_x'
if line_len == col_loc
execute 'normal! p'
else
execute 'normal! P'
endif
endfunction
xnoremap <silent> p :call Put_text_without_override_register()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment