OOZOU
Get in Touch
Back to TIL
vim

Quickly move lines up and down in any Vim mode

October 13, 2020

I often move lines around in vim so I have created mappings to make this easier. These map to ⌘-j for move down and ⌘-k for move up. Works in normal, insert, and visual modes. vim nnoremap <D-j> :m .+1<CR>== nnoremap <D-k> :m .-2<CR>== inoremap <D-j> <Esc>:m .+1<CR>==gi inoremap <D-k> <Esc>:m .-2<CR>==gi vnoremap <D-j> :m '>+1<CR>gv=gv vnoremap <D-k> :m '<-2<CR>gv=gv I use MacVim so I have used D(⌘) for the modifier key. To use in terminal based vims, use a different modifier e.g. <A-j>

More on vim

vimOctober 13, 2020

How to quit Vim

1. Install latest version of Vim 2. Open a file in Vim 3. ⌘-Q and close the terminal 4. Reopen terminal

vimOctober 13, 2020

How to really!! quit vim

In terminal

vimOctober 13, 2020

How to save a file with sudo in VIM

How to save a file with sudo in VIM

Have a project in mind?

We'd love to hear what you're building.

Start a Conversationhello@oozou.com
OOZOU Logo

Bangkok · Singapore · Hong Kong

X
Facebook
Instagram
LinkedIn

Services

  • Web Development
  • AI Agents & Generative AI
  • Mobile App Development
  • Data Analytics & Engineering
  • UI/UX & Product Design
  • Digital Transformation

Company

  • About Us
  • Careers
  • Blog
  • Whitepapers
  • Case Studies
  • Today I Learned
  • Contact

More

  • Industries
  • Get an Estimate
  • Partner Network
© 2026 OOZOU. All rights reserved.
Privacy PolicyCode of ConductABAC Policy