What settings and commands does one need to perform to make comments like this in emacs:
/**
*
* something here
*/
Thanks.
An easy way is to define your own command for inserting this comment. Add this to your .emacs file:
(defun insert-doc-comment () (interactive)
(insert "/**\n * Brief description. Long description. \n * @param \n * @return \n * @exception \n * @see \n * @author \n */"))
Then bind the new command to a key of your liking:
(define-key global-map [(S-f1)] 'insert-doc-comment)
Now pressing Shift-F1 will insert a comment block like this:
/**
* Brief description. Long description.
* @param
* @return
* @exception
* @see
* @author
*/
You can build templates with emacs. Templates are skeletons for a file structure, and can be tied to files with specific extensions. For example, you can make a java template that applies to any new file you create with a .java extension, and you can make a C++ template that applies to any file you create with a .cpp extension (and another one for .h files if needed).
This wiki has more examples to help you get started with a C++ class template.
Use yasnippet snipept, if you're not using it yet, try it.
Put this in you snippets/**-mode/
# -*- mode: snippet -*-
# name: dock
# key: /*
# --
/*
* $1
*/
$0
or another version:
# -*- mode: snippet -*-
# name: docblock
# key: /**
# --
/**
* ${1:name} - ${2:short description}
* @${3:argv1}: $4
* @${5:argv2}: $6
*
* ${7:long description}
*/
$0
I got both two in my snippets/, by the way you should copy yasnippets-xx/snippets
to another place like ~/.emacs.d/snippets
, and put this in your .emacs
:
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
become every time you update yasnippet, the yasnippet-xx/snippets will replaced by the author's snippets, you can add/delete/modify
your own snippets in ~/.emacs.d/snippets
for your own needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With