Skip to content

Instantly share code, notes, and snippets.

@dahu
Created May 23, 2013 23:42
Show Gist options
  • Save dahu/5640326 to your computer and use it in GitHub Desktop.
Save dahu/5640326 to your computer and use it in GitHub Desktop.
Bubble visual selection horizontally within the line - primer
" BubbleLeft()
" Demo of bubbling in visual mode
" Barry Arthur, 2013-05-24
" When you get BubbleRight() working, collapse them into a
" single Bubble(dir) function.
function! BubbleLeft()
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
normal! `<v`>x
let len = len(@@)
normal! hP
exe "normal! v" . (len - 1) . "h"
let &selection = sel_save
let @@ = reg_save
endfunction
vnoremap <left> :<c-u>call BubbleLeft()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment