Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add VSCode snippets for Dev Docs #5003

Merged
merged 4 commits into from
Jul 1, 2022

Conversation

pedrosousa
Copy link
Contributor

Adds Visual Studio Code (VSCode) auto-complete snippets for the most common Hugo shortcodes used Developer Docs.

Available snippets:

Prefixes Description
asideheader Inserts an Aside shortcode with header text.
asidenoheader Inserts an Aside shortcode without a header.
ccol Surrounds the current selection with content-column shortcodes.
tblwrap Surrounds the current selection with table-wrap shortcodes.
directory Inserts a directory-listing shortcode.
headerfullfile Inserts a file header for a complete Markdown file.
metatitle Inserts meta title fields in existing Markdown header. Used to complement a full file header.
headerpartialfile Inserts a header for a partial Markdown file.
partialinclude or renderpartial Inserts a render shortcode to include content from a partial in the current document.

Triggering one of the available snippets will insert their body content at the current cursor position.

Additionally, the following snippets support surrounding existing text:

  • Aside with header
  • Aside without header
  • Surround with content-column
  • Surround with table-wrap

How to use

To enter a snippet:

  1. Enter the snippet prefix and press Ctrl+Space.
  2. Select the desired snippet and press Enter.
  3. (Optional) Enter or select a value for the first placeholder supported by the snippet, if any, and press Tab to move to the next placeholder. Keep replacing placeholders and pressing Tab. When there are no more placeholders, pressing Tab will end the process.

To surround existing content with a snippet:

  1. Select the text you wish to surround with a snippet.
  2. Enter the snippet prefix (temporarily replacing the selected text) and press Ctrl+Space.
  3. Select the desired snippet and press Enter. VSCode will insert the snippet body and paste the previously selected content in the correct location (determined by $TM_SELECTED_TEXT in the snippet configuration).
  4. (Optional) Enter or select a value for the first placeholder supported by the snippet, if any, and press Tab to move to the next placeholder. Keep replacing placeholders and pressing Tab. When there are no more placeholders, pressing Tab will end the process.

@kodster28
Copy link
Contributor

Tested these and they all work except for metatitle (no sure why, it looks the same).

Two small notes:

  1. On a Mac, you have to hit Command + Space.
  2. Would it make sense to add how to do this and available options to the readme?

@pedrosousa
Copy link
Contributor Author

pedrosousa commented Jul 1, 2022

metatitle is a special case. You must have the cursor inside an existing file header for it to work (tech details: the cursor must be in a YAML context, not a Markdown context).

Regarding the notes:

  1. Hmm, I see. I wasn't sure, so I mentioned the same keyboard shortcut as in Microsoft's documentation.
  2. Yes, I'll update the README as part of this PR.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 1, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 49ce63c
Status: ✅  Deploy successful!
Preview URL: https://5948a70b.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://pedro-add-vscode-snippets.cloudflare-docs-7ou.pages.dev

View logs

@pedrosousa pedrosousa merged commit 6040c27 into production Jul 1, 2022
@pedrosousa pedrosousa deleted the pedro/add-vscode-snippets branch July 1, 2022 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants