* Right justify the comments starting from the position of `#' for all lines.
@ 2021-09-27 9:54 Hongyi Zhao
2021-09-27 13:25 ` Daniel Fleischer
2021-09-28 3:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 6+ messages in thread
From: Hongyi Zhao @ 2021-09-27 9:54 UTC (permalink / raw)
To: help-gnu-emacs
Suppose I've the following code snippets:
foo ... # foo comments
bar ... # bar comments
baz ... # baz comments
[...]
Now, I want to right justify the comments starting from the position
of `#' for all lines. Any hints/tips for achieving this goal?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Right justify the comments starting from the position of `#' for all lines.
2021-09-27 9:54 Right justify the comments starting from the position of `#' for all lines Hongyi Zhao
@ 2021-09-27 13:25 ` Daniel Fleischer
2021-09-27 14:04 ` Hongyi Zhao
2021-09-28 3:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Fleischer @ 2021-09-27 13:25 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao [2021-09-27 Mon 17:54] wrote:
> Suppose I've the following code snippets:
>
> foo ... # foo comments
> bar ... # bar comments
> baz ... # baz comments
> [...]
>
> Now, I want to right justify the comments starting from the position
> of `#' for all lines. Any hints/tips for achieving this goal?
Can highlight the lines, use 'align-regexp' and then enter '#'.
--
Daniel Fleischer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Right justify the comments starting from the position of `#' for all lines.
2021-09-27 13:25 ` Daniel Fleischer
@ 2021-09-27 14:04 ` Hongyi Zhao
2021-09-27 14:43 ` Daniel Fleischer
0 siblings, 1 reply; 6+ messages in thread
From: Hongyi Zhao @ 2021-09-27 14:04 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: help-gnu-emacs
On Mon, Sep 27, 2021 at 9:25 PM Daniel Fleischer <danflscr@gmail.com> wrote:
>
> Hongyi Zhao [2021-09-27 Mon 17:54] wrote:
>
> > Suppose I've the following code snippets:
> >
> > foo ... # foo comments
> > bar ... # bar comments
> > baz ... # baz comments
> > [...]
> >
> > Now, I want to right justify the comments starting from the position
> > of `#' for all lines. Any hints/tips for achieving this goal?
>
> Can highlight the lines, use 'align-regexp' and then enter '#'.
Thank you very much. It really works. BTW, how to adjust/control/set
the position of the starting '#' in the ultimate aligned results?
Best, HZ
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Right justify the comments starting from the position of `#' for all lines.
2021-09-27 14:04 ` Hongyi Zhao
@ 2021-09-27 14:43 ` Daniel Fleischer
2021-09-27 15:18 ` Hongyi Zhao
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Fleischer @ 2021-09-27 14:43 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao [2021-09-27 Mon 22:04] wrote:
> Thank you very much. It really works. BTW, how to adjust/control/set
> the position of the starting '#' in the ultimate aligned results?
Call the function with 'C-u'. It will ask you some questions, use the
same '#' but you now can specify the "amount of spacing".
Another option is using the wonderful CUA-rectangle mode. It's very (!)
powerful but a bit hidden, see https://emacs.stackexchange.com/a/16902
for documentation. It allows you to create blocks, fill them with
strings, fill them with integers series, insert/append text, kill,
reverse, align, sort and more.
--
Daniel Fleischer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Right justify the comments starting from the position of `#' for all lines.
2021-09-27 14:43 ` Daniel Fleischer
@ 2021-09-27 15:18 ` Hongyi Zhao
0 siblings, 0 replies; 6+ messages in thread
From: Hongyi Zhao @ 2021-09-27 15:18 UTC (permalink / raw)
To: Daniel Fleischer; +Cc: help-gnu-emacs
On Mon, Sep 27, 2021 at 10:43 PM Daniel Fleischer <danflscr@gmail.com> wrote:
>
> Hongyi Zhao [2021-09-27 Mon 22:04] wrote:
>
> > Thank you very much. It really works. BTW, how to adjust/control/set
> > the position of the starting '#' in the ultimate aligned results?
>
> Call the function with 'C-u'. It will ask you some questions, use the
> same '#' but you now can specify the "amount of spacing".
>
> Another option is using the wonderful CUA-rectangle mode. It's very (!)
Do you use `!' for emphasizing?
> powerful but a bit hidden, see https://emacs.stackexchange.com/a/16902
> for documentation.
The corresponding source code is located at
<https://github.com/emacs-mirror/emacs/blob/79b5d66bd66458f6e669adee2698e9fd18c4bc3a/lisp/emulation/cua-base.el#L131-L251>.
> It allows you to create blocks, fill them with
> strings, fill them with integers series, insert/append text, kill,
> reverse, align, sort and more.
Thank you for letting me know about it
HZ
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Right justify the comments starting from the position of `#' for all lines.
2021-09-27 9:54 Right justify the comments starting from the position of `#' for all lines Hongyi Zhao
2021-09-27 13:25 ` Daniel Fleischer
@ 2021-09-28 3:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-28 3:39 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
> Suppose I've the following code snippets:
>
> foo ... # foo comments
> bar ... # bar comments
> baz ... # baz comments
> [...]
>
> Now, I want to right justify the comments starting from the
> position of `#' for all lines. Any hints/tips for achieving
> this goal?
The mode should do this for you, see `comment-column'.
But the way to use comments is to use it when something sticks
out in a weird way or in a way that's difficult to understand
by just looking at the code.
If you do this all the time comments won't help ...
And if you do this very rarely as you should, aligning the
comment manually is not a problem.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-28 3:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-27 9:54 Right justify the comments starting from the position of `#' for all lines Hongyi Zhao
2021-09-27 13:25 ` Daniel Fleischer
2021-09-27 14:04 ` Hongyi Zhao
2021-09-27 14:43 ` Daniel Fleischer
2021-09-27 15:18 ` Hongyi Zhao
2021-09-28 3:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.