Neovim Lua Config, Keymaps, and Autocmds/Map line movement in visual mode

Move selected lines up or down.

Section: Lua keymaps

Map line movement in visual mode

lua
lua
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
Explanation

A common productivity pattern for rearranging blocks.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Lua keymaps
Map a save command
Bind a normal-mode key to save the file.
OpenIn sheetluasame section
Map Telescope file search
Bind a key to file-finding with a Lua callback.
OpenIn sheetluasame section
Set the leader key
Define your custom mapping prefix.
OpenIn sheetlua3 tag match
Enable line numbers
Turn on absolute and relative line numbers.
OpenIn sheetlua2 tag match
Create an autocmd
Run code when matching files are written.
OpenIn sheetlua2 tag match
Configure tabs and indentation
Set width and spacing rules.
OpenIn sheetlua2 tag match