Jason Song
Jason Song

Reputation: 165

How to show new line in the hint generated from comment in VS Code

When using VS Code, I want my block comments shown with the new line when I move the cursor onto it. Currently it is presented in just one line as below. I did google online but didn't find anything related. Any advice would be appreciated!

VSCode Version 1.59.0

Commit 379476f0e13988d90fab105c5c19e7abc8b1dea8

Related Issue C/C++ doc comments preview doesn't react to newlines (Should be fixed yet)

enter image description here

Update 8.28:

(1) In my case, @brief, @param, etc have an effect of removing newline of the following statement, and Markdown grammar cannot be interpreted in my VS Code, e.g.

enter image description here

(2) The only way it works is using pure block comments like this:

enter image description here

Upvotes: 7

Views: 7134

Answers (3)

user3589448
user3589448

Reputation: 21

Related to a previous answer in this issue - what worked for me, was to start and end a code example section, just to create a newline. Not entirely sure if this is a good practice, but it works for me.

/** * this is some text. * ``` * ``` * this is some text on the next line. */

Upvotes: 0

Hans GD
Hans GD

Reputation: 94

In my experience, in VS Code 1.76.2 you can separate paragraphs only in the @note section by adding more @note

Note section adds paragraphs

I don't have more extensions besides the default C/C++ by Microsoft

Upvotes: 5

Mike Lischke
Mike Lischke

Reputation: 53337

You cannot influence how normal text is rendered. It's interpreted as Markdown text with collapsed whitespaces. The only way to do at least partially what you want is to format (a part of) the text as code, just like you can do here at Stackoverflow (triple back tick block):

    /**
     * Converts the given position to one which is relative to this context.
     *
     * ```ts
     * let i: number = 1;
     * const a = true;
     * ```
     *
     * @param value The position to convert.
     *
     * @returns The position in local space.
     */
    public toLocal(value: IPosition): IPosition {
        return {
            lineNumber: value.lineNumber - this.presentation.startLine + 1,
            column: value.column,
        };
    }

enter image description here

Upvotes: 6

Related Questions