tpope / vim-rsi

rsi.vim: Readline style insertion
http://www.vim.org/scripts/script.php?script_id=4359
583 stars 35 forks source link

respect dot operator #45

Open Konfekt opened 6 years ago

Konfekt commented 6 years ago

:help i_CTRL-G_U gives examples of movement mappings in insert mode that respect the dot operator, for example <home>, <end>, <left>, <right>. How about vim-rsi piggybacking on these, for example,

inoremap <expr> <C-A> col('.') == match(getline('.'), '\S') + 1 ?
                      \ repeat('<C-G>U<Left>', col('.') - 1) :
                      \ (col('.') < match(getline('.'), '\S') ?
                      \     repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :
                      \     repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))
inoremap <expr> <C-E> col('.')>strlen(getline('.'))<bar><bar>pumvisible()?"\<Lt>C-E>":repeat("\<Lt>C-G>U\<Lt>Right>", col('$') - col('.'))
inoremap <expr> <C-B> getline('.')=~'^\s*$'&&col('.')>strlen(getline('.'))?"0\<Lt>C-D>\<Lt>Esc>kJs":"\<Lt>C-G>U\<Lt>Left>"
inoremap <expr> <C-F> col('.')>strlen(getline('.'))?"\<Lt>C-F>":"\<Lt>C-G>U\<Lt>Right>"