Loading ...
Sorry, an error occurred while loading the content.

Folds

Expand Messages
  • Tom
    Hello. Often doing programming I come across the case that I would like to have folds for Class and/or API code. e.g; [code] // Javascript function MyClass() {
    Message 1 of 2 , Apr 2, 2012
    • 0 Attachment
      Hello.

      Often doing programming I come across the case that I would like to
      have folds for Class and/or API code. e.g;

      [code]
      // Javascript
      function MyClass() {
      }

      /**
      * Some API Docs
      */
      MyClass.prototype.someMethod = function() {
      };

      ...
      [/code]

      What I usually do here is create a manual fold for each API doc and
      method. But this is a lot of manual work with e.g. "V$%jzf" to fold a
      method. I'd like to do this automatically for the whole document with
      one <leader> map. Is this possible?

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Tim Chase
      ... Does this one work for you? g/^ / * *//{$/norm $V%jzf which is roughly on every line matching /** at the beginning, search forward for the first { at
      Message 2 of 2 , Apr 2, 2012
      • 0 Attachment
        On 04/02/12 08:25, Tom wrote:
        > [code]
        > // Javascript
        > function MyClass() {
        > }
        >
        > /**
        > * Some API Docs
        > */
        > MyClass.prototype.someMethod = function() {
        > };
        >
        > ...
        > [/code]
        >
        > What I usually do here is create a manual fold for each API doc and
        > method. But this is a lot of manual work with e.g. "V$%jzf" to fold a
        > method. I'd like to do this automatically for the whole document with
        > one<leader> map. Is this possible?

        Does this one work for you?

        g/^\/\*\*//{$/norm $V%jzf


        which is roughly "on every line matching '/**' at the beginning,
        search forward for the first '{' at the end of a line. Then, in
        normal mode, do your incantation to go visual at the EOL, jump to
        the matching close-brace, go down one line, and then fold it"

        -tim


        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      Your message has been successfully submitted and would be delivered to recipients shortly.