" 1 common nnoremap ' : nnoremap . cd $VIMCONFecho 'change directory to ' $VIMCONF nnoremap d DduSelectorCall filer "" nnoremap d Fern %:h -reveal=% nnoremap Q confirm qa " based from https://github.com/habamax/.vim/blob/5ae879ffa91aa090efedc9f43b89c78cf748fb01/plugin/mappings.vim?plain=1#L152 " HLとPageDown/PageUpを共用する function s:pagedown() abort let line = line('.') let topline = winsaveview().topline normal! L if line == line('.') " 末尾にいたらPageDown normal! ztL endif if line('.') == line('$') " 行末に来たらウィンドウの末尾と最下行を合わせる normal! z- if winsaveview().topline != topline " サクラエディタ風の挙動 " 既に行末にいる場合以外は元の行末にカーソルを置く execute line else endif endif normal! 0 endfunction function s:pageup() abort let line = line('.') let topline = winsaveview().topline normal! H if line == line('.') " 先頭にいたらPageUp normal! zbH endif let newtopline = winsaveview().topline if newtopline == 1 && topline != newtopline " 上と同じく execute line endif normal! 0 endfunction "" ref: https://blog.atusy.net/2024/05/29/vim-hl-enhanced/ nnoremap (vimrc-page) nnoremap (vimrc-page)j call pagedown()(vimrc-page) nnoremap (vimrc-page)k call pageup()(vimrc-page) nnoremap j (vimrc-page)j nnoremap k (vimrc-page)k " shellのcd用ヘルパー ""/tmp/fish_cdにカレントファイルのディレクトリパスを書き込んでVimを落とす nnoremap call writefile([expand('%:p:h')], '/tmp/fish_cd')confirm qa " source current file "" 評価中の関数は上書きできないのでfeedkeysを使ってexprっぽいことをする function s:source() abort let cmdcr = "\%s\" let echo = printf(cmdcr, "echo 'sourced'") if !has('nvim') && &filetype ==# 'lua' " in vim, can't source lua file directly call feedkeys(printf(cmdcr, 'luafile %') .. echo) else call feedkeys(printf(cmdcr, 'source %') .. echo) endif endfunction nnoremap so call source() " sugoi undo nnoremap U " tab nnoremap H tabprevious nnoremap L tabnext nnoremap to tabonly nnoremap tq tabclose nnoremap tt tab split " window movement nnoremap w nnoremap sh h nnoremap sj j nnoremap sk k nnoremap sl l " yank operation "" L nnoremap call vimrc#denops#request('yank', 'yank', [getline(1, '$')]) " こまめなセーブは忘れずに nnoremap s update " スクロール位置をトップからのPageDown幅に合わせる "" function! s:align() abort "" let pos = getcurpos()[1:] "" let view = winsaveview() "" normal! gg "" while v:true "" let cl = line('.') "" if line('w0') <= pos[0] && pos[0] <= line('w$') "" call cursor(pos) "" return "" endif "" execute "normal! \" "" if cl == line('.') "" call winrestview(view) "" echomsg 'wtf?' "" endif "" endwhile "" endfunction "" HL PageDown対応版 function! s:align() abort let pos = getcurpos()[1:] let view = winsaveview() normal! gg while v:true let cl = line('.') if line('w0') <= pos[0] && pos[0] <= line('w$') call cursor(pos) return endif normal! Lzt if cl == line('.') call winrestview(view) echomsg 'wtf?' endif endwhile endfunction nnoremap gm call align() " ファイルを介したクリップボードもどき nnoremap p call vimrc#feat#clipboard#load() nnoremap y call vimrc#feat#clipboard#save() " フォーマットかけるやつ nnoremap mf call vimrc#feat#format#execute_filetype()