Increment/decrement plugin using denops.vim
(日本語版はこちら)
NOTICE: This plugin is work-in-progress yet. User interface is subject to
change without notice.
Extended increment/decrement plugin for
Vim/Neovim.
Written in Deno, using
denops.vim.
This plugin is a reimplementation of
dial.nvim plugin for the following
purposes:
This plugin depends on Deno and
denops.vim.
Plug 'vim-denops/denops.vim'
Plug 'monaqa/dps-dial.vim'
By adding the following description to the configuration file, you can change
the behavior of <C-a>
and <C-x>
:
nmap <C-a> <Plug>(dps-dial-increment)
nmap <C-x> <Plug>(dps-dial-decrement)
xmap <C-a> <Plug>(dps-dial-increment)
xmap <C-x> <Plug>(dps-dial-decrement)
xmap g<C-a> g<Plug>(dps-dial-increment)
xmap g<C-x> g<Plug>(dps-dial-decrement)
You can perform string operations according to the following rules:
Date Increase/Decrease
7<C-a>
on 25
in 2021/08/25
, you will get the date one2021/09/01
.7<C-a>
on 08
, then you will get2022/03/25
.Toggle between camelCase
and snake_case
g:dps_dial#augends
.Switch arbitrary words
['true', 'false']
or [ 'Mon', 'Tue', ..., 'Sun' ]
.g:dps_dial#augends
.User extension
Unlike the standard dot repeating in <C-a>
/ <C-x>
, dps-dial.vim
provides
dot repeating with a fixed increment/decrement rule. For example, suppose you
have a buffer like the following, and you want to move all due dates back one
month:
date: 2020/11/08
...
due date of 1st report: 2020/11/23
...
due date of 2nd report: 2020/12/21
...
date of exam: 2021/01/14
In dps-dial.vim
, it can be achieved by the following simple operations:
11
in the first line 2020/11/08
and press <C-a>
(this will2020/12/08
)date
and jump to the third line at date
.
(this will change the date in the third line to2020/12/23
)n.n.
(the date will be incremented by one month for line 5 and 7 asNote that if you press <C-a>
at step3, the 1
part of 1st
will be
incremented. Dot-repeat remembers that the previous operation was to increment
the month of the date by one, so you can skip the number 1st
and just
increment the date.
The increment/decrement is done according to the rules set ing:dps_dial#augends
.
function! s:dps_dial_settings() abort
let g:dps_dial#augends += ['boolean']
call extend(g:dps_dial#aliases, {
\ 'boolean': {
\ 'kind': 'constant',
\ 'opts': {
\ 'elements': ['true', 'false'],
\ 'word': v:true,
\ 'cyclic': v:true,
\ },
\ },
\ })
endfunction
autocmd User DenopsPluginPost:dial call <SID>dps_dial_settings()
Note that if there is a buffer-local variable b:dps_dial_augends
, it will be
used as the configuration.
autocmd FileType python let b:dps_dial#augends = ['decimal', {'kind': 'constant', 'opts': {'elements': ['True', 'False']}}]
"x<C-a>
instead of <C-a>
, the increment will be performedg:dps_dial#augends#register#x
instead ofg:dps_dial#augends
."1<C-a>
instead of <C-a>
, the behavior of subsequent"X<C-a>
instead of <C-a>
, the increment will be performedg:dps_dial#augends#register#x
instead ofg:dps_dial#augends
, and the behavior of subsequent dot-repeat will beSee vim help for a list of augend and aliases (currently only Japanese).
:help dps-dial.txt
MIT