summaryrefslogtreecommitdiff
path: root/lua/tjk/keybindings.lua
blob: 563d843dbef5a8a65a55275aa05c8730d34162b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local key = vim.keymap.set

vim.g.mapleader = ","

-- toggle spellcheck
key("n", "<leader>l", [[:setlocal spell! spelllang=en_us<CR>]])
-- toggle cursorcolumn
key("n", "<leader>c", [[:set cursorcolumn!<CR>]])

-- scroll doc with ctrl+[jk]
key({ "n", "v" }, "<C-j>", "<C-e>")
key({ "n", "v" }, "<C-k>", "<C-y>")
-- go to begining or end of line with ctrl+[hl]
key({ "n", "v" }, "<C-h>", "zh")
key({ "n", "v" }, "<C-l>", "zl")

-- split navigation with ctrl+shift+[hjkl]
key("n", "<C-S-h>", "<C-w>h")
key("n", "<C-S-j>", "<C-w>j")
key("n", "<C-S-k>", "<C-w>k")
key("n", "<C-S-l>", "<C-w>l")

-- browser like tab shortcuts
key("n", "<C-Tab>", "gt")
key("n", "<C-S-Tab>", "gT")
--key("n", "<C-t>", [[:tabe<CR>]])
--key("n", "<C-w>", [[:tabclose<CR>]]) -- <C-w> is already used lol
-- additional tab shortcuts
key("n", "<C-t>", "gt")
key("n", "<C-T>", "gT")


-- copy text to x11 buffer
key("", "<C-c>", [["+y]])
key("", "<C-x>", [["+x]])
key("", "<C-S-c>", [["+y]])
key("", "<C-S-x>", [["+x]])

-- unmap ex mode
key("", "Q", "<NOP>")

-- repeat commands with visual blocks using period
key("v", ".", [[:normal .<CR>]])

-- save files with root permissions with command `w!!`
key("c", "w!!", [[execute 'silent! write !doas tee % >/dev/null' <bar> edit!]])