Reference article: https://www.cnblogs.com/zzqcn/p/4660615.html
Writing comments for your own code is a good habit, and writing Doxygen-style comments can generate documentation for the code yourself through the doxygen tool, which is very easy to use. DoxygenToolkit (https://github.com/vim-scripts/DoxygenToolkit.vim) is one such plugin. The Doxygen plugin is automatically installed with the Vundle plugin manager. First install Vundle:
1. git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
If the directory .vim/bundle does not exist, please create it first
2. Add the following content to ~/.vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Vundle set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp + = ~ / .vim / bundle / Vundle.vim call vundle # begin () " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim / Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo "Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html "Plugin 'L9' " Git plugin not hosted on GitHub "Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) "Plugin 'file:///home/gmarik/path/to/plugin' " The sparkup vim script is in a subdirectory of this repo called vim. " Pass the path to set the runtimepath properly. "Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Avoid a name conflict with L9 "Plugin 'user/L9', {'name': 'newL9'} " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
As you can see from the comments in it, Vundle supports many forms of plugin sources, and examples are given. These plugin sources include: plugins on github, plugins on http://vim-scripts.org/vim/scripts.html, git plugins not on github, plugins on local hard drives, etc.
3. Open vim and run the :PluginInstall command to automatically install the plugin. In the process, you may need to enter the github username and password. Wait for the Vundle installation to complete.
Install Doxygen:
Add the source location of DoxygenToolkit in the Vundle plugins list area in ~/.vimrc
Plugin 'vim-scripts/DoxygenToolkit.vim'
The Vundle area in .vimrc is as follows:
After saving, exit, open vim again, and run the :PluginInstall command to install.
After installing Doxygen, open the code file, you can add license description, author version description and function description through :DoxLic, :DoxAuthor, :Dox. I integrated the license description and author version description, and added the variable of the company name. , and modified the author's version note field alignment, these modifications are done in ~/.vim/bundle/DoxygenToolkit.vim/plugin/DoxygenToolkit.vim. code show as below:
First modify the variable, licenseTag uses COMPANY as a placeholder for the company name, which is easy to replace with the company name defined in .vimrc:
let s:licenseTag = "Unpublished copyright. All rights reserved. This material contains\<enter>" let s:licenseTag = s:licenseTag . "proprietary information that should be used or copied only within\<enter>" let s:licenseTag = s:licenseTag . "COMPANY, except with written permission of COMPANY.\<enter>"
if !exists("g:DoxygenToolkit_briefTag_lic_pre") let g:DoxygenToolkit_briefTag_lic_pre = "@brief: " endif if !exists("g:DoxygenToolkit_briefTag_pre") let g:DoxygenToolkit_briefTag_pre = "@brief: " endif if !exists("g:DoxygenToolkit_fileTag") let g:DoxygenToolkit_fileTag = "@file: " endif if !exists("g:DoxygenToolkit_authorTag") let g:DoxygenToolkit_authorTag = "@author: " endif if !exists("g:DoxygenToolkit_dateTag") let g:DoxygenToolkit_dateTag = "@date: " endif if !exists("g:DoxygenToolkit_versionTag") let g:DoxygenToolkit_versionTag = "@version: " endif
Modify the DoxygenLicenseFunc function to integrate the author version information. The default version number here is 1.0. When adding the author version information separately, enter the version number
"""""""""""""""""""""""""" " Doxygen license comment """""""""""""""""""""""""" function! <SID>DoxygenLicenseFunc() call s:InitializeParameters() " Test authorName variable if !exists("g:DoxygenToolkit_companyName") let g:DoxygenToolkit_companyName = input("Enter name of your company: ") endif if !exists("g:DoxygenToolkit_authorName") let g:DoxygenToolkit_authorName = input("Enter name of the author (generally yours...) : ") endif mark d " Get file name let l:fileName = expand('%:t') let l:year = strftime("%Y") let l:copyright = "Copyright (c) " let l:copyright = l:copyright.l:year." ".g:DoxygenToolkit_companyName."." let l:license = substitute( g:DoxygenToolkit_licenseTag, "\<enter>", "\<enter>".s:interCommentBlock, "g" ) let l:license = substitute( l:license, "COMPANY", g:DoxygenToolkit_companyName, "g" ) exec "normal O".s:startCommentBlock exec "normal o".s:interCommentTag.l:copyright."\<enter>".s:interCommentTag exec "normal o".s:interCommentTag.l:license exec "normal o".s:interCommentTag.g:DoxygenToolkit_fileTag.l:fileName exec "normal o".s:interCommentTag.g:DoxygenToolkit_briefTag_lic_pre mark d exec "normal o".s:interCommentTag.g:DoxygenToolkit_authorTag.g:DoxygenToolkit_authorName exec "normal o".s:interCommentTag.g:DoxygenToolkit_versionTag."1.0" let l:date = strftime("%Y-%m-%d") exec "normal o".s:interCommentTag.g:DoxygenToolkit_dateTag.l:date if( s:endCommentBlock != "" ) exec "normal o".s:endCommentBlock endif exec "normal `d" call s:RestoreParameters() startinsert! endfunction
Then add the following code block to .vimrc:
vi open the code file, you can use the shortcut key to comment on the code, the company name is xxxx, the effect is as follows: