Skip to content

Commit 568f405

Browse files
sand4rtLouis Louis
authored andcommitted
feat(keymap): move windows without <C-w> (nvim-lua#1368)
1 parent c0e8849 commit 568f405

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

init.lua

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,61 @@ vim.opt.scrolloff = 10
166166
vim.opt.confirm = true
167167

168168
-- [[ Basic Keymaps ]]
169+
<<<<<<< HEAD
169170
require 'keymaps'
171+
=======
172+
-- See `:help vim.keymap.set()`
173+
174+
-- Clear highlights on search when pressing <Esc> in normal mode
175+
-- See `:help hlsearch`
176+
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
177+
178+
-- Diagnostic keymaps
179+
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
180+
181+
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
182+
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
183+
-- is not what someone will guess without a bit more experience.
184+
--
185+
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
186+
-- or just use <C-\><C-n> to exit terminal mode
187+
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
188+
189+
-- TIP: Disable arrow keys in normal mode
190+
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
191+
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
192+
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
193+
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
194+
195+
-- Keybinds to make split navigation easier.
196+
-- Use CTRL+<hjkl> to switch between windows
197+
--
198+
-- See `:help wincmd` for a list of all window commands
199+
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
200+
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
201+
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
202+
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
203+
204+
-- NOTE: Some terminals have coliding keymaps or are not able to send distinct keycodes
205+
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
206+
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
207+
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
208+
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
209+
210+
-- [[ Basic Autocommands ]]
211+
-- See `:help lua-guide-autocommands`
212+
213+
-- Highlight when yanking (copying) text
214+
-- Try it with `yap` in normal mode
215+
-- See `:help vim.highlight.on_yank()`
216+
vim.api.nvim_create_autocmd('TextYankPost', {
217+
desc = 'Highlight when yanking (copying) text',
218+
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
219+
callback = function()
220+
vim.highlight.on_yank()
221+
end,
222+
})
223+
>>>>>>> e947649 (feat(keymap): move windows without `<C-w>` (#1368))
170224

171225
-- [[ Install `lazy.nvim` plugin manager ]]
172226
require 'lazy-bootstrap'

0 commit comments

Comments
 (0)