Last active
September 6, 2021 13:01
-
-
Save AnsonH/0691db0064192fdc54c5a6879c6746dd to your computer and use it in GitHub Desktop.
Vim Tip #3 - Move lines up and down with <A-k> and <A-j>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <silent> <A-j> :m .+1<CR>== | |
nnoremap <silent> <A-k> :m .-2<CR>== | |
inoremap <silent> <A-j> <Esc>:m .+1<CR>==gi | |
inoremap <silent> <A-k> <Esc>:m .-2<CR>==gi | |
vnoremap <silent> <A-j> :m '>+1<CR>gv=gv | |
vnoremap <silent> <A-k> :m '<-2<CR>gv=gv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://vim.fandom.com/wiki/Moving_lines_up_or_down#Mappings_to_move_lines
I added the
<silent>
argument so that it doesn't output the mapping in the Vim command line