Skip to content

Instantly share code, notes, and snippets.

@joechrysler
Created January 11, 2012 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joechrysler/1595171 to your computer and use it in GitHub Desktop.
Save joechrysler/1595171 to your computer and use it in GitHub Desktop.
Move lines of code around using vim's directional keys
" Pop the following into your .vimrc
" Move a line of text using CTRL+[arrows]
nmap <C-down> mz:m+<cr>`z
nmap <C-up> mz:m-2<cr>`z
nmap <C-left> <<
nmap <C-right> >>
vmap <C-down> :m'>+<cr>`<my`>mzgv`yo`z
vmap <C-right> :m'<-2<cr>`>my`<mzgv`yo`z
"" Move around split windows with CTRL+[jkhl]
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment