jamalsenouci / sublimetext-syntaxfold Goto Github PK
View Code? Open in Web Editor NEWSublime Text Plugin that provides a configurable command and popup for folding code based on syntax
License: MIT License
Sublime Text Plugin that provides a configurable command and popup for folding code based on syntax
License: MIT License
OS: Mac OS X 10.10.2
Using the Menu Option "Add Another Config" creates a File Named "Packages\User\syntax_fold.sublime-settings" instead of creating the file "syntax_fold.sublime-settings" in the Folder "Packages\User".
Hello all,
i downloaded this plugin today for sublimtext3 & install it but after that when i whrite
#pragma region enum WeekDay { Dimanche,Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi }; #pragma endregion
and did "alt+1", but nothing happened...
did i do something wrong ?
Thx !!
My specific scenario is in Javascript with a multiline template string.
{
"scope": "source.js",
"startMarker": "query = `",
"endMarker": "`"
}
this causes a line like this:
function someFunc() {
let query = `
SELECT foo
FROM bar
`;
}
to look like this (code folding character omitted):
function someFunc() {
let query = `
`;
}
I was expecting it to look like this (code folding character omitted):
function someFunc() {
let query = ``;
}
Tried this on a javascript and php files but nothing happens.
and this appears on the console:
SyntaxFold: No start markers or end markers found in file. Aborting request.
Although my file does contain start and end markers
I didn't touch any setting the first time , then i separated javascript:
{
"scope": "source.js",
"startMarker":"{region",
"endMarker":"}endregion"
}
but that didn't work as well.
Am i missing something here or is it a bug ?
When I define the following region
{
"endMarker": "*--#]",
"name": "FORM",
"startMarker": "*--#["
}
I cannot fold.
Just an idea for improvement: Please support PHP heredocs.
Hi there,
I'm trying to get support for COD - using a syntax like below. Any thoughts ... I don't know if it will work because the start and end tags are formatted as comments by the syntax highlighter.
Any help would be great. Cheers.
/***
@Class QueryRequest
***/
public class QueryRequest {
/***
@Property BaseObject
@type String
@summary Stores the name of the base object of the query request.
***/
public String BaseObject { get; set; }
}
how can i fold region with "startMarker": "/*region*/"
and "endMarker": "/*endregion*/"
Is this possible at all? because i can't make this working :(
It'd be nice to have a single shortcut/keybind to toggle the fold rather than two separate keybinds for opening/closing specifically. If it's unfolded then fold it, if it's folded then unfold it.
I am using c# coding.
This plugins suddenly stopped working on this previous update, but I tried it a lot working now.
//syntax_fold.sublime-settings
{
"endMarker": "#endregion",
"name": "C#",
"scope": "source.cs", <-- Add line
"startMarker": "#region"
},
I hope this will help:)
This is an awesome plugin : )
However, I am currently running into the following issue:
After folding & unfolding the code several times, I am left with multiple artifacts of "bookmark" symbols in the left gutter. Is there a way to disable bookmarks from SyntaxFold entirely? I do not see a use for them, as regular code fold symbols should be all that is needed, & the bookmark symbols obscure them.
All the keybinds used to work perfectly. For whatever unknown reason they stopped working and now the folding only works by using the Command Palette.
Any solutions for this problem?
Hello,
I tried folding html and js, nothing happens
sometimes doing alt+0 or alt+1 switch the current edited document to another one, but appart from that
my code is never altered
waht am I missing ?
thanks
Hi, I notice that when I fold all the regions, the triangle folder sign will appear on the specific position. This is great, but the problem is that when I unfold single region by clicking the triangle, the original sign will disappear. Can you still keep the triangle unfold sign when I do unfold operation?
Thank you!
Is it possible to fold from a startMarker to the end of the file?
eg. With "startMarker" = "##" and no "endMarker" defined:
## Section 1
This is foldable
## Section 2
This is not foldable
Thanks for the plugin.
can you provide an example for config for python syntax
I've just installed in Sublime Text 3 - and attempted to get it working with C# style regions in JavaScript:
//#region Test
CODE
//#endregion
using the following config:
{
"endMarker": "//#endregion",
"name": "JavaScript #region",
"startMarker": "//#region"
}
But I can't seem to get the plugin to do anything?
Not quite clear how to use this.
I want to fold knitr markdown code chunks
I tried putting this in Packages/User/syntax_fold.sublime_settings but I don't get offered knitr as an option when I press shift F5. What do I need to add?
"knitr":
{
"endMarker": "```$",
"name": "Knitr",
"startMarker": "```\\{r(.*)\\}"
}
Hi,
I am using your Plugin and it works really well. It would be nice to have a toggle folding command, so one has to rememeber only a single keyboard shortcut.
Greetings!
I hope this finds you well. Having gone along with the recent ST4 update, I believe SyntaxFold might need an update to function. When ya go to fold all the code, it folds it according to ST's syntax. I've tried resinstalling, etc., doesn't seem to help. Thanks in advance for you time and consideration. Cheers!
Does this plugin handle folding of HTML code? Or, do I need to configure that in the settings?
Package control still picks up the older version before fix #40 - update package control at https://packagecontrol.io/packages/SyntaxFold
Hello
Was trying to use syntaxfold for LaTeX but I am not sure if I am using it in the wrong way, or if it just doesn't work for what I want.
Basically, my config looks like:
{
"endMarker": "\\end{",
"name": "LaTeX",
"startMarker": "\\begin{"
},
and as you might expect, marker lines continue with more characters up to the end of the line.
It seems it doesn't work with this kind of markers at the moment. I am right?
Also, does it have any problem with nested regions?
best,
I have the toggle and unfold commands working fine, but fold all doesn't seem to work at all. I noted that in the status bar a message appears saying '1 regions folded' but no code is folded at all. I have tried with different key bindings but it doesn't work. I am on OS X in ST4. Thanks for any advice.
Hi. :)
I wondered if you can make everything between "#region" and "#endregion", including "#region" and "#endregion" in a box, when folded ( nothing outside ). When unfolded the name after "#region" is in a box too, with the name ( even when unfolded ). Clicking the box unfolds and folds the region. :)
I've noticed that regions inside regions are not folded. Can this be solved? :)
Another idea is that everything is folded by default ( no need to save states ). Even when copying code into Sublime Text, the regions automatically folds.
An additional thing would be an arrow to the left ( like with "{" and "}" ), if possible. :)
I hope this is something that can be implemented.
Best regards,
Johannes Hillestad Baumann
I don't think it works but I might be missing somethng: So, like:
//region
some stuff
//region
other suff
//endregion
more stuff
//endregion
So in SyntaxFold.py:
class FoldPanelCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.panel_cache = []
self.config_map = {}
s = sublime.load_settings('syntax_fold.sublime-settings')
configs = s.get("config")
for conf in configs:
c=dict()
c['startMarker']=conf.get('startMarker')
c['endMarker']=conf.get('endMarker')
if conf['name']=="Default":
descr=startMarker <--------------------------------------------------
this value is not defined
console says the same
NameError: global name 'startMarker' is not defined
Cheers
It is possible to save the state of folding regions when closing a file to load it again when reopening the file again.
The shortcuts [ALT]+[0] and [ALT]+[SHIFT]+[0] are known to me, but somtimes i had some regions folded others dont folded.
The informations of the folding states could be stored in the fileheader itself (like Vims modeline see here) or as dotfile inside the directory of the file.
Ideally changeable via User-Settings of SyntaxFold.
master from today (commit:5dbc247
), Sublime Text 3 build 4169, OSX 14.4.1.
the default settings have been pared down to an empty file, and the user settings only have one entry now:
{
"config":[
{
"scope": "source.c++, source.c",
"startMarker": [ "#pragma region", "#ifdef", "#ifndef", "#if" ],
"endMarker": [ "#pragma endregion", "#endif", "#else", "#elif" ],
},
]
}
The test C file I have created:
#if foo
void some_func(void)
{
do_the_thing();
}
#endif
If I check the scope I see source.c meta.preprocessor.c
which should match the scope in the user settings above.
Doesn't matter where I have the cursor (start, middle or end of #if foo
, somewhere in the block, start or end of #endif
), nothing happens. If I open the console, I see this:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1499, in run_
return self.run(edit)
File "/Users/andrew/Library/Application Support/Sublime Text 3/Packages/SyntaxFold/SyntaxFold.py", line 187, in run
fold_regions = get_all_fold_regions(self.view)
File "/Users/andrew/Library/Application Support/Sublime Text 3/Packages/SyntaxFold/SyntaxFold.py", line 98, in get_all_fold_regions
start_positions, end_positions = get_all_positions(view,marker_pair)
File "/Users/andrew/Library/Application Support/Sublime Text 3/Packages/SyntaxFold/SyntaxFold.py", line 67, in get_all_positions
start_markers = view.find_all(start_marker)
File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1416, in find_all
return sublime_api.view_find_all(self.view_id, pattern, flags)
TypeError: String required
I was getting an error about the .cs syntax folding which is why I cleared out the default settings file and focused on the user settings one.
It would be nice, if Sublime Text SyntaxFold will support folding text in single line.
I use Sublime Text TableEditor plugin for tables creating. Example table:
I can have a long text in a cell.
Big monitor:
Small monitor โ bad table:
I want fold text, if line length in a cell is long. But I can't do it.
User/syntax_fold.sublime-settings
:
{
"config":
[
{
"scope": "text.genius.kira",
"startMarker": "!fold",
"endMarker": "!end"
}
]
}
Demo__SyntaxFold--Kireopardy.kira
:
Parts of Demo__SyntaxFold--Kireopardy.kira
:
!fold Sasha Best !end
!fold
Sasha Leader
!end
I run fold_all
command (Alt+0, Alt+0).
Multiline and single-line texts fold:
Multiline text fold, single-line not:
Thanks.
installed syntaxfold. added:
//region test
//endregion.
After hitting the hotkey, this shows up in the console and nothing happens.
"At least start marker must be specified. Aborting request."
Hi,
Looks like the folding is not working for me.
I'm trying to make it work for python (*.py) files and I want the startMarker to be literal text #;{
and endMarker to be literal text #;}
. Note that #
is the start of a comment in python.
So in Preferences > Package Settings > SyntaxFold > Settings - User
I tried to add
,
{
"scope": "python.py",
"startMarker": "#;{",
"endMarker": "#;}"
}
and I also tried without the scope
line - the folding still doesn't work for me.
What am I doing wrong and how to achieve what I want?
As part of code introduced with PR #39 the functionality was added to:
Adding ability to specify different regions within the same source code type.
When one of these regions report 0 matches for both the start and end markers, the fold aborts even if there is other legitimate matches in other regions.
current block will not "unfold" if cursor is located within start marker line. It must be positioned at the end.
# region First Region...
------------^ (cursor position) will not unfold
# region First Region...
-----------------------^ (cursor position) works
Mac OS X (High Sierra version 10.13.6), Sublime 3.1.1 Build 3176
I can not use "[" and "]" as start and end regions for folding areas.
SyntaxFold settings:
{ "scope": "text.plain", "startMarker":"[", "endMarker":"]" }
I can use <>, {}, but not [], and also not ().
I'd like to know why this is the case.
In the *--#[ and *--#] region markers not working issue, it's said that special characters must be escaped, however, when i do so, the console shows me the following:
error: Error trying to parse settings: Invalid escape in Packages\User\syntax_fold.sublime-settings:25:27
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.