Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It depends on whether there's a consistent form to the licence block and what language you're programming in. For example, python tends to use a 'foldexpr' to define folding, so to add this you'd have to replace the existing function with a new one (or get rid of the existing folding). I believe the default in C is to use manual folding (although it's possible that I configured it that way myself: I can't remember), so this is much easier to add extra folding.</p> <p>With a simple GPL copyright message like the one at the end of this post, you could set foldmethod to manual and have a simple function that creates a fold. It all depends on the form of the copyright and how important it is for you to maintain the existing folding. I'm afraid I'd need a bit more detail to give a more useful answer. Anyway, here's an example script that could be used to fold the copyright notice at the end of this post:</p> <pre><code>function! CreateCopyrightFold() let InCopyright = 0 set foldmethod=manual for Line in range(1,line('$')) let LineContents = getline(Line) if LineContents !~ "^#" if InCopyright let CopyrightEnd = Line - 1 exe CopyrightStart . ',' . CopyrightEnd . 'fold' endif break elseif LineContents =~ "Copyright" let InCopyright = 1 let CopyrightStart = Line endif endfor endfunction au BufRead *.py call CreateCopyrightFold() </code></pre> <p>Assuming a copyright notice like this one:</p> <pre><code># Copyright (C) 2009 Some Company or Something # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys # Code continues... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload