" mapleader let g:mapleader = ',' nnoremap xnoremap " disable dengerous/annoying mapping " NOTE: ZQ is useful when cmdline is broken nnoremap ZZ nnoremap q nnoremap S xnoremap q " Record/execute macro like ["x]Q (in default use "q" register) nnoremap Q 'q' .. (!empty(reg_recording()) ? '' \ : stridx('"*+', v:register) > -1 ? 'q' : v:register) xnoremap Q ':normal! @' .. \ (stridx('"*+', v:register) > -1 ? 'q' : v:register) .. '' nnoremap j gj nnoremap k gk nnoremap gj j nnoremap gk k xnoremap j gj xnoremap k gk xnoremap gj j xnoremap gk k nnoremap x "_x nnoremap s "_s nnoremap Y y$ xnoremap x "_x xnoremap s "_s xnoremap Y y$ nnoremap n n(search-post) nnoremap N N(search-post) nnoremap * *(search-post) nnoremap # #(search-post) nnoremap g* g*(search-post) nnoremap g# g#(search-post) " disable arrow keys nnoremap nnoremap nnoremap nnoremap xnoremap xnoremap xnoremap xnoremap inoremap inoremap inoremap inoremap " better aliases of / nnoremap H getline('.')[:col('.') - 2] =~# '^\s*$' ? '0' : '^' nnoremap L xnoremap H getline('.')[:col('.') - 2] =~# '^\s*$' ? '0' : '^' xnoremap L inoremap u inoremap u nnoremap [Space] nmap [Space] nnoremap nohlsearchdiffupdate nnoremap [Space]w update nnoremap [Space]W write nnoremap ^ edit nnoremap [Space]f edit %:p:h nnoremap [Space]q confirm qall nnoremap gf gF nnoremap p ]p nnoremap P ]P xnoremap p P cnoremap / getcmdtype() ==# '/' ? '\/' : '/' cnoremap ? getcmdtype() ==# '?' ? '\?' : '?' " open native cmdline nnoremap g/ / " select last yanked/pasted text " from https://github.com/pesblog/dots-base/blob/a0762b8f/home/.vimrc#L140 " https://github.com/ibhagwan/nvim-lua/blob/dc846e06/lua/keymaps.lua#L133 nnoremap g $'`[{visualmode()}`]' " from https://vim-jp.org/vim-users-jp/2009/08/31/Hack-65.html xnoremap / /\%V " from https://github.com/nnsnico/dotfiles/blob/cf9ce83c/vim/vimrcs/basic.vim#L150-L151 " center horizontally on cursor position nnoremap z. zszH " based on https://github.com/romgrk/nvim/blob/ba305c52/rc/keymap.vim#L98-L99 nnoremap i getline('.') =~# '^\s*$' ? '"_cc' : 'i' " from https://github.com/monaqa/dotfiles/blob/de4bdb9f/.config/nvim/lua/rc/keymap.lua#L436 nnoremap dd empty(getline('.')) && v:count1 ==# 1 \ && v:register ==# '"' ? '"_dd' : 'dd' " NOTE: `g_` is almost same as `$h` xnoremap v mode() ==# 'v' ? 'g_' : 'v' xnoremap t xnoremap ) t) onoremap t onoremap ) t) inoremap zz inoremap setlocal paste! paste? inoremap " emacs-like insert/cmdline mode mapping {{{ noremap! inoremap user#is_at_end() ? '' : '' noremap! noremap! noremap! noremap! noremap! user#is_at_end() ? '' : '' inoremap user#is_at_end() ? 'gJ' : 'D' cnoremap call setcmdline( \ getcmdpos() > 1 ? getcmdline()[:getcmdpos() - 2] : '') noremap! " " }}} " Use backslack instead of ¥ map! ¥ map ¥ tmap ¥ map! map tmap " insert current file fullpath cnoremap =expand('%:p') " toggle options nnoremap [Toggle] nmap [Toggle] nnoremap [Toggle]w setlocal wrap! wrap? nnoremap [Toggle]n setlocal relativenumber! relativenumber? " buffer move nnoremap [b :bprevious nnoremap ]b :bnext nnoremap [B :bfirst nnoremap ]B :blast