I find a .vimrc file config:
" Move selection up/down (add =gv to reindent after move)
:vmap <D-S-Up> :m-2<CR>gv
:vmap <D-S-Down> :m'>+<CR>gv
I know the D-S-Up must be a key, but what is the key?
I type:
:help D-S-Up
nothing happened
I find a .vimrc file config:
" Move selection up/down (add =gv to reindent after move)
:vmap <D-S-Up> :m-2<CR>gv
:vmap <D-S-Down> :m'>+<CR>gv
I know the D-S-Up must be a key, but what is the key?
I type:
:help D-S-Up
nothing happened
:help key-notation
tells you the meaning of all those <key>
notations.
You can't expect :help D-S-Up
to do anything because:
i_ctrl-r
,<D>
is the Cmd
key on Mac keyboards, <S>
is the Shift
key, and <Up>
is the Up
arrow key.
So <D-S-Up>
means Cmd
+ Shift
+ Up
.
The Cmd
key only works in the MacVim GUI.
Non-portable mappings are worthless.
One should use :xmap
or :xnoremap
for visual mode mappings, not :v*
.
Non-recursive mappings should be used by default unless one really wants recursion.
Using someone else's vimrc
is a bad idea.
By the way, here are enhanced versions of those mappings:
nnoremap <silent> <D-S-Up> :<C-u>move-2<CR>==
nnoremap <silent> <D-S-Down> :<C-u>move+<CR>==
xnoremap <silent> <D-S-Up> :move-2<CR>gv=gv
xnoremap <silent> <D-S-Down> :move'>+<CR>gv=gv
where:
<silent>
prevents the commands in the mapping from echoing useless info,<C-u>
removes any default range inserted by Vim,move-2<CR>
is a more readable version of m-2<CR>
,==
re-indents the line,gv=gv
reselects the lines, re-indents them, and re-selects them again.Have a look at Move entire line up and down in Vim
In an answer you can read (concerning the line :vmap <D-S-Up> :m-2<CR>gv
):
According to the shortcuts above, pressing Cmd-Shift-Up/Down will shift the block selection up/down. "D" is the Command key in MacVim, for Windows try "C" (Control), or "A" (Alt) (eg. would be Control Alt f).
Since I don't have a Mac myself, I can't check, but it's most certainly true.