Skip to content

Commit

Permalink
feat: Create separate modifier keys for normal mode and visual mode (…
Browse files Browse the repository at this point in the history
…g:move_key_modifier_visualmode), both defaulting to Alt key
  • Loading branch information
tecfu committed Mar 13, 2022
1 parent d4fbf3b commit 6f4cab2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plugin/move.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if !exists('g:move_key_modifier')
let g:move_key_modifier = 'A'
endif

if !exists('g:move_key_modifier_visualmode')
let g:move_key_modifier_visualmode = 'A'
endif


if !exists('g:move_auto_indent')
let g:move_auto_indent = 1
endif
Expand Down Expand Up @@ -240,6 +245,10 @@ function s:MoveKey(key)
return '<' . g:move_key_modifier . '-' . a:key . '>'
endfunction

function s:VisualMoveKey(key)
return '<' . g:move_key_modifier_visualmode . '-' . a:key . '>'
endfunction

" Note: An older version of this program used callbacks with the "range"
" attribute to support being called with a selection range as a parameter.
" However, that had some problems: we would get E16 errors if the user tried
Expand All @@ -263,10 +272,10 @@ nnoremap <silent> <Plug>MoveCharLeft :<C-u> silent call <SID>MoveChar

if g:move_map_keys
execute 'vmap' s:MoveKey('j') '<Plug>MoveBlockDown'
execute 'vmap' s:MoveKey('k') '<Plug>MoveBlockUp'
execute 'vmap' s:MoveKey('h') '<Plug>MoveBlockLeft'
execute 'vmap' s:MoveKey('l') '<Plug>MoveBlockRight'
execute 'vmap' s:VisualMoveKey('j') '<Plug>MoveBlockDown'
execute 'vmap' s:VisualMoveKey('k') '<Plug>MoveBlockUp'
execute 'vmap' s:VisualMoveKey('h') '<Plug>MoveBlockLeft'
execute 'vmap' s:VisualMoveKey('l') '<Plug>MoveBlockRight'

execute 'nmap' s:MoveKey('j') '<Plug>MoveLineDown'
execute 'nmap' s:MoveKey('k') '<Plug>MoveLineUp'
Expand Down

0 comments on commit 6f4cab2

Please sign in to comment.