Hi! I like a code folding but simce i write Python in TM - code folding doesn't work right... Sometimes its ok but some - weird. So just stop fold code. Its fine but... Some time ago i read one article about Django and find some interesting idea in that article - code folding markers for vim. Here is a short description: we need to add new folding rule to fold code based on that pair of markers #{{{ def test ... #}}} add regexp for folding and some macros/snippets doesn't hard (i hope ;) and we will have working solution for Python (or any other lang) right now. I mean in 1.5+ version ;-)
Link to full story about folding in vim: http://www.amitu.com/blog/2007/july/vim-python-code-folding-and-my-vimrc/ Any ideas? I can't do it myself yet but i hope someone will...
Alexey
Oh! And BTW there a good idea about naming folding... i.e. # Super fold #{{{ ... # }}} folds to # Super fold...
IMO its nice. Isn't it?
On Dec 11, 2007 11:38 AM, Alexey Blinov nilcolor@gmail.com wrote:
Hi! I like a code folding but simce i write Python in TM - code folding doesn't work right... Sometimes its ok but some - weird. So just stop fold code. Its fine but... Some time ago i read one article about Django and find some interesting idea in that article - code folding markers for vim. Here is a short description: we need to add new folding rule to fold code based on that pair of markers #{{{ def test ... #}}} add regexp for folding and some macros/snippets doesn't hard (i hope ;) and we will have working solution for Python (or any other lang) right now. I mean in 1.5+ version ;-)
Link to full story about folding in vim: http://www.amitu.com/blog/2007/july/vim-python-code-folding-and-my-vimrc/
Any ideas? I can't do it myself yet but i hope someone will...
Alexey
On 11 Dec 2007, at 09:38, Alexey Blinov wrote:
[...] new folding rule to fold code based on that pair of markers #{{{ def test ... #}}} [...] I can't do it myself yet but i hope someone will...
Have a look at http://macromates.com/textmate/manual/navigation_overview#customizing_foldin... -- I wanted to say that if you can code Python, I am sure you can add the proper patterns, but then I remembered that Python lack regexps as first class citizens ;)
On Dec 11, 2007 1:28 PM, Allan Odgaard throw-away-2@macromates.com wrote:
On 11 Dec 2007, at 09:38, Alexey Blinov wrote:
[...] new folding rule to fold code based on that pair of markers #{{{ def test ... #}}} [...] I can't do it myself yet but i hope someone will...
Have a look at http://macromates.com/textmate/manual/navigation_overview#customizing_foldin... -- I wanted to say that if you can code Python, I am sure you can add the proper patterns, but then I remembered that Python lack regexps as first class citizens ;)
Thanks you for link.
So if anyone like an idea here what i do (im on the way to create some snippet to make fold-marking easier...)
#Python lang dict - change current folding regexp to # this one catch only next combo (w/o variants) # # some fold description # {{{ # ... # # }}} foldingStartMarker = '^#\s[\w\s]*(#\s{{{)$'; foldingStopMarker = '^#\s}}}$';
and it folds nice, leaving `# some fold description # {{{` visible so you can read your comment for that fold (i'd like to hide `# {{{` but can't found how yet...)
P.S. Still WIP and i'd like to hear some nice ideas ;)
Here, first atempt to create command to set surrounding folding markers. Thanks to Markdown bundle dev ;)
HTH
Alexey
P.S. Command code (not sure about attachment) -------------------------------------------------- #!/usr/bin/env ruby # just to remind you of some useful environment variables # see Help / Environment Variables for the full list $: << ENV['TM_SUPPORT_PATH'] + '/lib' require 'escape'
s = STDIN.read if s.empty? then print "# fold comment here # {{{\n\n# }}}" elsif ENV.has_key? 'TM_SELECTED_TEXT' print "# ${1:fold comment here} # {{{\n#{e_sn s}\n# }}}\n" else print "# hmm... not sure what is this... # {{{\n#{e_sn s}\n# }}}\n" end -------------------------------------------------- Input: Selected text or Line Output: Insert as Snippet
On Dec 11, 2007 2:11 PM, Alexey Blinov nilcolor@gmail.com wrote:
On Dec 11, 2007 1:28 PM, Allan Odgaard throw-away-2@macromates.com wrote:
On 11 Dec 2007, at 09:38, Alexey Blinov wrote:
[...] new folding rule to fold code based on that pair of markers #{{{ def test ... #}}} [...] I can't do it myself yet but i hope someone will...
Have a look at http://macromates.com/textmate/manual/navigation_overview#customizing_foldin... -- I wanted to say that if you can code Python, I am sure you can add the proper patterns, but then I remembered that Python lack regexps as first class citizens ;)
Thanks you for link.
So if anyone like an idea here what i do (im on the way to create some snippet to make fold-marking easier...)
#Python lang dict - change current folding regexp to # this one catch only next combo (w/o variants) # # some fold description # {{{ # ... # # }}} foldingStartMarker = '^#\s[\w\s]*(#\s{{{)$'; foldingStopMarker = '^#\s}}}$';
and it folds nice, leaving `# some fold description # {{{` visible so you can read your comment for that fold (i'd like to hide `# {{{` but can't found how yet...)
P.S. Still WIP and i'd like to hear some nice ideas ;)
Alexey Blinov wrote:
Hi! I like a code folding but simce i write Python in TM - code folding doesn't work right... Sometimes its ok but some - weird. [...] we need to add new folding rule to fold code based on that pair of markers #{{{ def test ... #}}}
No offense intended, but good god, that is ugly. I hope you don't have to share code that looks like that with anyone else.
Hopefully Allan will eventually add support foldings for languages with pretty syntax, as well as those which condone gratuitous ugly. ;) Until then, just stick to using whitespace for Python+TM folding--it works passably well.
-Jacob
No offense intended, but good god, that is ugly. I hope you don't have
to share code that looks like that with anyone else.
Hopefully Allan will eventually add support foldings for languages with pretty syntax, as well as those which condone gratuitous ugly. ;) Until then, just stick to using whitespace for Python+TM folding--it works passably well.
-Jacob
It works strange, atleast... Anyway - ugly - nice term but what do you
mean?