Coder Social home page Coder Social logo

prantlf / vscode-fold-on-open Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 2.0 72 KB

Folds comments or other targets in code files automatically when you open them.

License: MIT License

JavaScript 100.00%
fold fold-comments comments vscode vscode-extension

vscode-fold-on-open's Introduction

Fold on Open for Visual Studio Code

Logo license Build Status

Folds comments or other targets in code files automatically when you open them in Visual Studio Code.

Tip: If your code includes long JSDoc comments for generating the project documentation, you can fold them automatically when opening a file, so that you will be able to focus on the code and work more efficiently:

"foldOnOpen.targets": ["AllBlockComments"]

Installation

Install this extension to your Visual Studio Code from the marketplace, or download a specific version of a released package and install it from the file.

Configuration

This extension contributes the following settings. The names have to be prefixed by "foldOnOpen.", when entered to settings.json:

Name Description Type Default value Valid values
targets Targets to fold when a file is opened. Leave it empty to disable the automatic folding. string[] [] All, AllBlockComments, AllMarkerRegions, Level1, Level2, Level3, Level4, Level5, Level6, Level7, Recursively
enableFiles Enables the automatic folding for the specified file patterns only. All file patterns are enabled enabled by default. string[] ["**/*"] patterns known from files.exclude, e.g.
disableFiles Disables the automatic folding for the specified file patterns. No file patterns are disabled by default. string[] [] patterns known from files.exclude, e.g.

If a file pattern starts with /, it will match file paths from the file system root. If a file pattern starts with **, it will match the rest of the file path on any directory. If a file pattern start with neither / nor **, it will consider file paths starting in the project folder as the root.

Examples

Settings can be applied either for all files:

// enable initial block comment folding everywhere except for tests
"foldOnOpen.targets": ["AllBlockComments"],
"foldOnOpen.disableFiles": ["**/test/**/*"]

or scoped for a particular language:

// enable initial block comment folding only for JavaScript files and
// only in `src` directories in the project root
"[javascript]": {
    "foldOnOpen.targets": ["AllBlockComments"],
    "foldOnOpen.enableFiles": ["src/**/*.js"]
}

Additionally, you can decide to save the settings globally to User settings, or locally to Workspace or Project Folder settings. If you want to switch your settings independently on those locations, you can have a look at the Profile Switcher. Read also about settings scopes in VS Code.

Troubleshooting

If the JSDoc comments are not folded, you can try disabling the syntax-aware folding:

"editor.foldingStrategy": "indentation"

License

Copyright (c) 2020 Ferdinand Prantl

Licensed under the MIT license.

The logo was based on an original icon published among Octicons by GitHub under the Apache 2.0 license. Thank you!

vscode-fold-on-open's People

Contributors

prantlf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mrx23dot ib3n

vscode-fold-on-open's Issues

Very nice ! thanks

I was searching since a long time to, only, fold comments when opening a file.

The majority of addons like Autofold f.i. are folding everything below a given "level" so not really useful to me.

Folding just comment blocks is so great, thanks !

Fold doxygen comments too

Folding fails for these standard comments, please parse them, or provide regexp to customise them:

/**
multiline
 */ 

/// rst
/// rst
/// rst
/// rst
/*!
* ... text ...
*/
//!
//!... text ...
//!
/**********************************************
*  ... text
***********************************************/
/////////////////////////////////////////////////
/// ... text ...
/////////////////////////////////////////////////

Great Extension! Can we have a setting to only fold multi-line comments? /* */

Hi! I'm a computer science professor and I've been using your extension in my classes. I add instructions to the students using:

/* PartA -

  • blah blah blah
  • /

which works great! The minor annoyance is that, if I give them commented out code (using single line comments) without putting an extra blank line between them, they will fold as well.

For example:
// int a =5;
// int b = 4;

will fold unless I separate the lines:

// int a =5;

// int b = 4;

Would it be possible to have a "MultilineCommentsOnly" setting? This would make your extension perfect for my use cases!

Thanks! Great job!
Rich.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.