aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2021-11-29 10:10:52 +0900
committernsfisis <nsfisis@gmail.com>2021-11-29 10:10:52 +0900
commit616241470486ed2cd4098b12c72b49c66c083607 (patch)
treeb3d565bc1ffb33c86dfd14b16813ceeaf96f240c
parent942b477f438d61a5ccaf29d18d10df0ba9762424 (diff)
downloaddotfiles-616241470486ed2cd4098b12c72b49c66c083607.tar.gz
dotfiles-616241470486ed2cd4098b12c72b49c66c083607.tar.zst
dotfiles-616241470486ed2cd4098b12c72b49c66c083607.zip
neovim/vim: add key mappings to toggle some options
-rw-r--r--.config/nvim/init.lua27
-rw-r--r--.vimrc23
2 files changed, 50 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index b7a4249..e66e8b6 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -945,6 +945,33 @@ command! -nargs=+ -complete=command
+-- Toggle options {{{2
+
+vimrc.map('n', 'T', '<Nop>')
+
+vimrc.map('n', 'Tb', ':<C-u>if &background == "dark" <Bar>set background=light <Bar>else <Bar>set background=dark <Bar>endif<CR>', { silent = true })
+vimrc.map('n', 'Tc', ':<C-u>set cursorcolumn! <Bar>set cursorline!<CR>', { silent = true })
+vimrc.map('n', 'Td', ':<C-u>if &diff <Bar>diffoff <Bar>else <Bar>diffthis <Bar>endif<CR>', { silent = true })
+vimrc.map('n', 'Te', ':<C-u>set expandtab!<CR>', { silent = true })
+vimrc.map('n', 'Th', ':<C-u>set hlsearch!<CR>', { silent = true })
+vimrc.map('n', 'Tn', ':<C-u>set number!<CR>', { silent = true })
+vimrc.map('n', 'Ts', ':<C-u>set spell!<CR>', { silent = true })
+vimrc.map('n', 'T8', ':<C-u>if &textwidth ==# 80 <Bar>set textwidth= <Bar>else <Bar>set textwidth=80 <Bar>endif<CR>', { silent = true })
+vimrc.map('n', 'T0', ':<C-u>if &textwidth ==# 100 <Bar>set textwidth= <Bar>else <Bar>set textwidth=100 <Bar>endif<CR>', { silent = true })
+vimrc.map('n', 'T2', ':<C-u>if &textwidth ==# 120 <Bar>set textwidth= <Bar>else <Bar>set textwidth=120 <Bar>endif<CR>', { silent = true })
+vimrc.map('n', 'Tw', ':<C-u>set wrap!<CR>', { silent = true })
+
+vimrc.map('n', 'TB', 'Tb', { noremap = false })
+vimrc.map('n', 'TC', 'Tc', { noremap = false })
+vimrc.map('n', 'TD', 'Td', { noremap = false })
+vimrc.map('n', 'TE', 'Te', { noremap = false })
+vimrc.map('n', 'TH', 'Th', { noremap = false })
+vimrc.map('n', 'TN', 'Tn', { noremap = false })
+vimrc.map('n', 'TS', 'Ts', { noremap = false })
+vimrc.map('n', 'TW', 'Tw', { noremap = false })
+
+
+
-- Increment/decrement numbers {{{2
-- nnoremap + <C-a>
diff --git a/.vimrc b/.vimrc
index 04e11e1..bef1d50 100644
--- a/.vimrc
+++ b/.vimrc
@@ -289,6 +289,29 @@ nnoremap tc <C-w>c
nnoremap to <C-w>o
nnoremap <silent> tO :<C-u>tabonly<CR>
+nnoremap T <Nop>
+
+nnoremap <silent> Tb :<C-u>if &background == 'dark' <Bar>set background=light <Bar>else <Bar>set background=dark <Bar>endif<CR>
+nnoremap <silent> Tc :<C-u>set cursorcolumn! <Bar>set cursorline!<CR>
+nnoremap <silent> Td :<C-u>if &diff <Bar>diffoff <Bar>else <Bar>diffthis <Bar>endif<CR>
+nnoremap <silent> Te :<C-u>set expandtab!<CR>
+nnoremap <silent> Th :<C-u>set hlsearch!<CR>
+nnoremap <silent> Tn :<C-u>set number!<CR>
+nnoremap <silent> Ts :<C-u>set spell!<CR>
+nnoremap <silent> T8 :<C-u>if &textwidth ==# 80 <Bar>set textwidth= <Bar>else <Bar>set textwidth=80 <Bar>endif<CR>
+nnoremap <silent> T0 :<C-u>if &textwidth ==# 100 <Bar>set textwidth= <Bar>else <Bar>set textwidth=100 <Bar>endif<CR>
+nnoremap <silent> T2 :<C-u>if &textwidth ==# 120 <Bar>set textwidth= <Bar>else <Bar>set textwidth=120 <Bar>endif<CR>
+nnoremap <silent> Tw :<C-u>set wrap!<CR>
+
+nmap TB Tb
+nmap TC Tc
+nmap TD Td
+nmap TE Te
+nmap TH Th
+nmap TN Tn
+nmap TS Ts
+nmap TW Tw
+
nnoremap gh <Nop>
nnoremap gH <Nop>
nnoremap g<C-h> <Nop>