Something went wrong. Try again.
Personal Neovim configuration
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157---- Copyright (c) 2026 Jan Fooken---- 20_mappings.lua---- Add user defined key mappings and override some of Neovim's built-in key-- mappings to make the commands more intuitive---- For an overview of the predefined mappings refer to the relevant sections in-- |index| (type :help index).-- For information on how to define custom mappings refer to |mapping| (type-- :help mapping) and the Lua module |vim.keymap| (type :help vim.keymap).--local map = vim.keymap.set
-- Navigation ==================================================================
-- In Normal and Visual, but not Select mode, treat a wrapped line as new a line-- while navigating down.map( { 'n', 'x' }, 'j', function() return vim.v.count == 0 and 'gj' or 'j' end, { expr = true })map( { 'n', 'x' }, '<Down>', function() return vim.v.count == 0 and 'g<Down>' or '<Down>' end, { expr = true })
-- In Normal and Visual, but not Select mode, treat a wrapped line as new a line-- while navigating up.map( { 'n', 'x' }, 'k', function() return vim.v.count == 0 and 'gk' or 'k' end, { expr = true })map( { 'n', 'x' }, '<Up>', function() return vim.v.count == 0 and 'g<Up>' or '<Up>' end, { expr = true })
-- Open the netrw local-directory on the current file's directory in the current-- buffer. If you don't wish to use netrw, then you need to avoid loading both-- the plugin and the autoload portions of netrw by placing the following code-- snippet in your configuration. And delete this key mapping using-- |vim.keymap.del()|.-- >lua-- vim.g.loaded_netrw = 1-- vim.g.loaded_netrwPlugin = 1-- <map('n', '<Leader>e', '<CMD>Explore<CR>', { desc = 'Open netrw' })
-- Clipboard ===================================================================
-- Yank {motion} text into register "+" (system clipboard).map({ 'n', 'x' }, 'gy', '"+y', { desc = 'Yank to system clipboard' })
-- Yank [count] lines into register "+" (system clipboard) without trailing-- newline.map({ 'n', 'x' }, 'gY', '"+y$', { desc = 'Yank line to system clipboard' })
-- Put the text from register "+" (system clipboard) after the cursor [count]-- times. This mapping overrides |gp|.map('n', 'gp', '"+p', { desc = 'Paste from system clipboard' })
-- Put the text from register "+" (system clipboard) after the cursor [count]-- times without setting the defined register. See |v_P|.map('x', 'gp', '"+P', { desc = 'Paste from system clipboard' })
-- Miscellaneous ===============================================================
-- Shift the highlighted lines [count] 'shiftwidth' leftwards without leaving-- Visual mode.map('x', '<', '<gv')
-- Shift the highlighted lines [count] 'shiftwidth' rightwards without leaving-- Visual mode.map('x', '>', '>gv')
-- Open a window to show the location list for the current window.map('n', '<Leader>l', '<Cmd>lopen<CR>', { desc = 'Open location list' })
-- Open a window to show the current list of errors.map('n', '<Leader>q', '<Cmd>copen<CR>', { desc = 'Open quickfix list' })
-- Start Visual mode with the same area as the previous area and the same mode-- as the previously changed or yanked text. This mapping overrides |gV|.map('n', 'gV', '"`[" . strpart(getregtype(), 0, 1) . "`]"', { desc = 'Visually reselect changed or yanked text', expr = true, replace_keycodes = false,})
-- Search ======================================================================
-- Search forward for the [count]'th occurrence of the word nearest to the-- cursor. When searching, don't immediately jump to the next occurrence.map({ 'n', 'x' }, '*', '*N')
-- Same as "*", but search backward.map({ 'n', 'x' }, '#', '#N')
-- Like "*", but don't put "\<" and "\>" around the word. This makes the search-- also find matches that are not a whole word.map('n', 'g*', 'g*N')
-- Like "#", but don't put "\<" and "\>" around the word. This makes the search-- also find matches that are not a whole word.map('n', 'g#', 'g#N')
-- Comment in to repeat the latest "/" or "?" [count] times, while keeping the-- cursor centred.--map('n', 'n', 'nzz')
-- Comment in to repeat the latest "/" or "?" [count] times in opposite-- direction, while keeping the cursor centred.--map('n', 'N', 'Nzz')
-- Search forward inside the Visual area for the [count]'th occurrence of-- {pattern} |exclusive|. This mapping overrides |/|.map( 'x', '/', '<C-\\><C-N>/\\%V', { desc = 'Search forward inside selection', silent = false })
-- Search backward inside the Visual area for the [count]'th previous occurrence-- of {pattern} |exclusive|. This mapping overrides |?|.map( 'x', '?', '<C-\\><C-N>?\\%V', { desc = 'Search backward inside selection', silent = false })
-- Abbreviations ===============================================================
-- Quit the current window.map('ca', 'Q', 'q')
-- Quit without writing, also when the current buffer has changes.map('ca', 'Q!', 'q!')
-- Write the whole buffer to the current file.map('ca', 'W', 'w')
-- Write the whole buffer to the current file and quit the current window-- afterwards.map('ca', 'Wq', 'wq')