Last Updated: February 25, 2016
·
806
· shocm

Move lines in VIM like PHPStorm

One of my favorite features of PHPStorm in the ability to move a line of code up or down by using the key combination (on OSX) command-shift-up and command-shift-down.

Being more of a VI guy I wanted to mimic this behavior in VIM so I created the following mapping:

nnoremap <silent> <leader>k ddkP
nnoremap <silent> <leader>j ddp

Now with my leader key and k, the line of code I am on moves up and with leader key and j the line moves down.

2 Responses
Add your response

You can also try vim-move plugin by matze ( https://github.com/matze/vim-move ). It's works quite faster for me rather than native solution.

over 1 year ago ·

Thanks @dimko-desu I'll give it a try.

over 1 year ago ·