OOZOU
與我們聯繫
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

有專案構想嗎?

我們很樂意聆聽您正在打造的產品。

開始對話hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn

服務

  • Web 開發
  • AI 與生成式 AI 解決方案
  • 行動應用程式開發
  • 資料分析與工程
  • UI/UX 設計與產品設計
  • 數位轉型

公司

  • 關於我們
  • 職涯
  • 部落格
  • 白皮書
  • 案例研究
  • Today I Learned
  • 聯繫我們

更多

  • 產業
  • 索取報價
  • 合作夥伴網絡
© 2026 OOZOU. 版權所有。
隱私政策行為準則反賄賂反貪腐政策