Skip to content

Instantly share code, notes, and snippets.

@ak4bento
Created December 23, 2020 04:08
Show Gist options
  • Save ak4bento/0717cc71bad49f3ecf9e15d80fdf6197 to your computer and use it in GitHub Desktop.
Save ak4bento/0717cc71bad49f3ecf9e15d80fdf6197 to your computer and use it in GitHub Desktop.
" shift+arrow selection
nmap <S-Up> v<Up>
nmap <S-Down> v<Down>
nmap <S-Left> v<Left>
nmap <S-Right> v<Right>
vmap <S-Up> <Up>
vmap <S-Down> <Down>
vmap <S-Left> <Left>
vmap <S-Right> <Right>
imap <S-Up> <Esc>v<Up>
imap <S-Down> <Esc>v<Down>
imap <S-Left> <Esc>v<Left>
imap <S-Right> <Esc>v<Right>
" Replace global character selection
vnoremap ; :call Get_visual_selection()<cr>
function! Get_visual_selection()
" Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][col1 - 1:]
let selection = join(lines,'\n')
let change = input('Change the selection with: ')
execute ":%s/".selection."/".change."/g"
endfunction
" Mapping Selection for next occourance
let g:multi_cursor_use_default_mapping=0
" Default mapping
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<A-n>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment