2

In vim plugin 'tpope/vim-speeddating', it support wide variaty of date formats. e.g.

 %Y-%m-%d%[ T_-]%H:%M             2019-08-04 07:42
 %Y-%m-%d                         2019-08-04

But how to add my custom data formats, e.g.

 %Y/%m/%d                         2019/08/04
 %Y/%m                            2019/08
1

According to the documentation: (help speeddating)

One can use the :SpeedDatingFormat command to list, add, and remove formats. A good place to place custom formats is in .vim/after/plugin/speeddating.vim

For the formats you listed:

SpeedDatingFormat %Y/%m/%d
SpeedDatingFormat %Y/%m
0

Write these lines in your ~/.vimrc

au BufEnter * :SpeedDatingFormat %Y/%m/%d
au BufEnter * :SpeedDatingFormat %Y/%m
  • 1
    I think using the VimEnter autocmd should work as well? That way it won't be re-run every time you enter a buffer, which probably isn't needed (I think?) – Martin Tournoij Aug 4 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.