Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bbcode.php on line 2958
Vim's folding functionality (attn vince ;)
Results 1 to 4 of 4

Thread: Vim's folding functionality (attn vince ;)

  1. #1

    Vim's folding functionality (attn vince ;)

    Ok, I have a question about folding in Vim.

    I added these lines to the syntax highlighting definition file for perl:

    syn region perlFold start="{" end="}" transparent fold
    syn region perlFold start="(" end=")" transparent fold
    syn sync fromstart
    set foldmethod=syntax
    In theory, this will allow me to collapse any code block that is enclosed by curly braces, or regular brackets, and it does that in practise (sort of).

    The problem is that is only allows me to fold the code if it is nested. (ie, it won't let me fold a top-level code block, but it will let me fold the code blocks within it).

    Here's a screenshot to help clarify:

    Any ideas?

    (this nesting problem only seems to apply to curly brackets. Vim can fold 'top-level' regular brackets just fine)

  2. #2

    Re: Vim's folding functionality (attn vince ;)

    I couldn't say. I make my life much easier by using Visual Line mode, using zf to create a fold, and then using za to fold, unfold. Also, I'm not very fond of folding; if I need to see 2 parts of a text, I generally use screen spliting.

  3. #3

    Re: Vim's folding functionality (attn vince ;)

    Ah, ok. I don't like making folds manually, because I have to remake them every time I open the file. I like to collapse large functions when I'm trying to work out how a large script works (once I get the gist of a function I can just collapse it and say "and then this happens here...&quot.

    Thx anyway, though.

  4. #4

    Re: Vim's folding functionality (attn vince ;)

    Nevermind, i did some poking around in the file and it turns out it already has proper folding in it (just disabled by default). It looks like this:

     syn region perlPackageFold start="^package \S\+;$" end="^1;$" end="^package"me=s-1 transparent fold keepend
     syn region perlSubFold   start="^\z(\s*\)sub\>.*[^};]$" end="^\z1}\s*$" end="^\z1}\s*\#.*$" transparent fold keepend
     syn region perlBEGINENDFold start="^\z(\s*\)\(BEGIN\|END\)\>.*[^};]$" end="^\z1}\s*$" transparent fold keepend
     syn sync fromstart
     setlocal foldmethod=syntax

Similar Threads

  1. NetBIOS required for full functionality
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-01-2005, 09:29 PM
  2. Replies: 12
    Last Post: 02-08-2002, 02:15 AM
  3. Vince comes and goes
    By in forum General Chat
    Replies: 19
    Last Post: 01-26-2002, 11:23 AM
  4. Backing up LFS (attn Ralinx)
    By Feztaa in forum Linux - Software, Applications & Programming
    Replies: 7
    Last Post: 01-20-2002, 06:28 PM
  5. autoindent in vim (attn GnuVince :))
    By Feztaa in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 01-03-2002, 02:43 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts