Skip to content

Commit

Permalink
Ensure macOS compatibility for line- and block movement keymappings
Browse files Browse the repository at this point in the history
The keymappings implemented in GH-31 works fine on Linux systems,
but conflicts with a global (non-modifyable) system keymapping on
macOS. Therefore a condition check for the currently running
environment should be used to use other specific keymappings for macOS
and Linux.

Resolves GH-172
  • Loading branch information
arcticicestudio committed Jan 16, 2019
1 parent 631ab5f commit 59a5cc5
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions snowblocks/vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,26 @@ map <C-n> :NERDTreeToggle<CR>
" Moves the current line or selected block(s) up- or down by one line.
"
" In normal -and insert mode the "==" re-indents the moved line to suit its new position.
" In visual mode "gv" reselects the last visual block while the "=" re-indents that block using the preassigned "'>" mark to identify the selection end.
nnoremap <C-Down> :m+<CR>==
nnoremap <C-Up> :m-2<CR>==
inoremap <C-Down> <Esc>:m+<CR>==gi
inoremap <C-Up> <Esc>:m-2<CR>==gi
vnoremap <C-Down> :m '>+1<CR>gv=gv
vnoremap <C-Up> :m '<-2<CR>gv=gv
" In visual mode "gv" reselects the last visual block while the "=" re-indents that block using the
" preassigned "'>" mark to identify the selection end.
" Note that due to a global (non-modifyable) system keymapping on macOS it is necessary to use environment
" specific assignments.

if has("macunix")
nnoremap <C-S-Down> :m+<CR>==
nnoremap <C-S-Up> :m-2<CR>==
inoremap <C-S-Down> <Esc>:m+<CR>==gi
inoremap <C-S-Up> <Esc>:m-2<CR>==gi
vnoremap <C-S-Down> :m '>+1<CR>gv=gv
vnoremap <C-S-Up> :m '<-2<CR>gv=gv
else
nnoremap <C-Down> :m+<CR>==
nnoremap <C-Up> :m-2<CR>==
inoremap <C-Down> <Esc>:m+<CR>==gi
inoremap <C-Up> <Esc>:m-2<CR>==gi
vnoremap <C-Down> :m '>+1<CR>gv=gv
vnoremap <C-Up> :m '<-2<CR>gv=gv
endif

"+---------------+
"+ Configuration +
Expand Down

0 comments on commit 59a5cc5

Please sign in to comment.