mirror of
https://github.com/CompeyDev/my-nvim-setup.git
synced 2024-12-12 21:00:38 +00:00
add some useful keymap in insert/command mode with switch to toggle (#240)
Co-authored-by: curtain <kaleidoscope@163.com>
This commit is contained in:
parent
f805cb1cbd
commit
2b331e7fa1
2 changed files with 46 additions and 0 deletions
|
@ -103,6 +103,13 @@ local M = {
|
|||
toggle_right = "<leader>v",
|
||||
toggle_bot = "<leader>h"
|
||||
},
|
||||
unix_keymap = {
|
||||
toggle_unix_keymap = "<leader>k",
|
||||
forward = "<C-f>",
|
||||
backward = "<C-b>",
|
||||
top_of_line = "<C-a>",
|
||||
end_of_line = "<C-e>"
|
||||
},
|
||||
misc = {
|
||||
esc_Termmode = "jk",
|
||||
copywhole_file = "<C-a>",
|
||||
|
|
|
@ -24,6 +24,45 @@ map("v", "x", [=[ "_x ]=], opt)
|
|||
this line too ]]
|
||||
--
|
||||
|
||||
-- toggle unix readline's keymap
|
||||
map("n", user_map.unix_keymap.toggle_unix_keymap,"<cmd>lua require 'mappings'.unix_keymap()<CR>",{nowait = true})
|
||||
|
||||
local _cmap_containp = function (key)
|
||||
local cmap_tab = vim.api.nvim_get_keymap("c")
|
||||
|
||||
for _, value in ipairs(cmap_tab) do
|
||||
if value['lhs'] == key then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.unix_keymap = function()
|
||||
local m = user_map.unix_keymap
|
||||
|
||||
if _cmap_containp("<C-A>") then
|
||||
vim.api.nvim_del_keymap("i", m.forward)
|
||||
vim.api.nvim_del_keymap("i", m.backward)
|
||||
vim.api.nvim_del_keymap("i", m.top_of_line)
|
||||
vim.api.nvim_del_keymap("i", m.end_of_line)
|
||||
vim.api.nvim_del_keymap("c", m.forward)
|
||||
vim.api.nvim_del_keymap("c", m.backward)
|
||||
vim.api.nvim_del_keymap("c", m.top_of_line)
|
||||
vim.api.nvim_del_keymap("c", m.end_of_line)
|
||||
else
|
||||
map("i", m.forward, '<Right>', opt)
|
||||
map("i", m.backward, '<Left>', opt)
|
||||
map("i", m.top_of_line, '<ESC>^i', opt)
|
||||
map("i", m.end_of_line, '<End>', opt)
|
||||
vim.api.nvim_set_keymap("c", m.forward, '<Right>', {noremap = true})
|
||||
vim.api.nvim_set_keymap("c", m.backward, '<Left>', {noremap = true})
|
||||
vim.api.nvim_set_keymap("c", m.top_of_line, '<Home>', {noremap = true})
|
||||
vim.api.nvim_set_keymap("c", m.end_of_line, '<End>', {noremap = true})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Don't copy the replaced text after pasting in visual mode
|
||||
map("v", "p", '"_dP', opt)
|
||||
|
||||
|
|
Loading…
Reference in a new issue