ArashM
ArashM

Reputation: 1409

Similar plugin to Atom's docblockr in vim? (auto document methods)

Is there any plugin for Vim that inserts documentation template for each method when coding like docblockr in Atom? I googled it but results are irrelevant.

Upvotes: 3

Views: 1111

Answers (2)

icc97
icc97

Reputation: 12863

I'm only familiar with the Sublime Text DocBlockr, but the Atom DocBlockr is a port of this so they should be functionally the same.

I've found nothing to match the power of DocBlockr after trying numerous failed attempts. I'm using GVim 8.0 on Windows.

vim-jsdoc mentioned by @MisterOccan gets close but it's only for JavaScript. You can set this to request for input (via let g:jsdoc_allow_input_prompt = 1 in your .vimrc) which allows you to set the values in a similar way to DocBlockr.

For PHP development the best I've found is the updated PDV v2 from TobyS. This combines with the UltiSnips plugin which allows tabbing though the generated doc (via Ctrl+j / Ctrl+k). So this actually gives a relatively close approximation to DocBlockr.

However

  1. PDV v2 doesn't generate @return values I'm not sure why (just one of the many niggles I've come across)
  2. PDV v1 (and it's clones the most recent being php-doc-modded) does generate @return values, but lacks the formatting and the ability to tab through the inputs
  3. None of the PHP documentors nicely format to the same extent the types and descriptions to line up vertically as with DocBlockr
  4. None of them have the autocomplete for adding extra tags
  5. The type hinting seemed to work better in DocBlockr than and of the Vim plugins that I tried

Edit: You can actually fix the PHP doc block formatting by using the Tabular plugin, with the following command:

:Tabularize /\$\w*/l1

This will match all the $xxx (\$\w*) variable names for the @param lines and pad them appropriately (using left align (l) with one space (1)).

Other plugins that I tried:

Upvotes: 1

MisterOccan
MisterOccan

Reputation: 11

There is no universal plugin for all file types, but a few plugins for specific ft:

e.g


EDIT: Another way is to use snippets.


Its always a good idea to search vim plugins in github instead of vim.org.

Upvotes: 1

Related Questions