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

Folding with shell syntax

Expand Messages
  • vim@henkis.net
    Fellow vim users! I am in great need of using function folding, and i have tried to enable it with the syntax folding, but i can t get it to work. Since there
    Message 1 of 9 , Nov 29, 2004
    • 0 Attachment
      Fellow vim users!

      I am in great need of using function folding, and i have tried to enable it
      with the syntax folding, but i can't get it to work.

      Since there seem to be support for folding in the syntax file, cant i just
      enable it by a simple command, like "syntax on" but "folding on"?

      set foldmethod=syntax and enabling folding does not seem to work.

      I'm using VIM 6.3...

      Thanks for any pointers, google was unable to help me ;)

      /Henrik
    • Sonic_Wind
      Hello Henrik, Monday, November 29, 2004, 2:35:02 PM, you wrote: vhn Fellow vim users! vhn I am in great need of using function folding, and i have tried to
      Message 2 of 9 , Nov 29, 2004
      • 0 Attachment
        Hello Henrik,

        Monday, November 29, 2004, 2:35:02 PM, you wrote:

        vhn> Fellow vim users!

        vhn> I am in great need of using function folding, and i have tried to enable it
        vhn> with the syntax folding, but i can't get it to work.

        vhn> Since there seem to be support for folding in the syntax file, cant i just
        vhn> enable it by a simple command, like "syntax on" but "folding on"?

        vhn> set foldmethod=syntax and enabling folding does not seem to work.

        vhn> I'm using VIM 6.3...

        vhn> Thanks for any pointers, google was unable to help me ;)

        vhn> /Henrik

        set foldmethod=syntax " means that syntax regions will be folded
        " the discription of such rigions must contain
        " fold key word
        for C-like languages this might looks like:
        sy region myFold start="{" end="}" fold transparent
        , so what language do you use.

        --
        Cheers,
        Wind mailto:sonic_wind@...
      • vim@henkis.net
        ... It s shell scripts .sh files, syntax highlighting works fine. But do i have to define them with start and end if the syntaxfile supports folding, should i
        Message 3 of 9 , Nov 29, 2004
        • 0 Attachment
          On Mon, Nov 29, 2004 at 04:17:40PM +0200, Sonic_Wind wrote:
          > Hello Henrik,
          >
          > Monday, November 29, 2004, 2:35:02 PM, you wrote:
          >
          > vhn> Fellow vim users!
          >
          > vhn> I am in great need of using function folding, and i have tried to enable it
          > vhn> with the syntax folding, but i can't get it to work.
          >
          > vhn> Since there seem to be support for folding in the syntax file, cant i just
          > vhn> enable it by a simple command, like "syntax on" but "folding on"?
          >
          > vhn> set foldmethod=syntax and enabling folding does not seem to work.
          >
          > vhn> I'm using VIM 6.3...
          >
          > vhn> Thanks for any pointers, google was unable to help me ;)
          >
          > vhn> /Henrik
          >
          > set foldmethod=syntax " means that syntax regions will be folded
          > " the discription of such rigions must contain
          > " fold key word
          > for C-like languages this might looks like:
          > sy region myFold start="{" end="}" fold transparent
          > , so what language do you use.

          It's shell scripts .sh files, syntax highlighting works fine. But do i have to
          define them with start and end if the syntaxfile supports folding, should i not be able to just start the folding?

          Thanks
          Henrik

          > --
          > Cheers,
          > Wind mailto:sonic_wind@...
        • Sonic_Wind
          Hello vim, Monday, November 29, 2004, 5:16:33 PM, you wrote: vhn It s shell scripts .sh files, syntax highlighting works fine. But do i have to vhn define
          Message 4 of 9 , Nov 29, 2004
          • 0 Attachment
            Hello vim,

            Monday, November 29, 2004, 5:16:33 PM, you wrote:


            vhn> It's shell scripts .sh files, syntax highlighting works fine. But do i have to
            vhn> define them with start and end if the syntaxfile supports
            vhn> folding, should i not be able to just start the folding?
            No, no one are able to just start folding ( you are able to just
            start folding only for foldmethod=indent). You have to explain to vim
            what do you whant to be folded out.
            In syntax/sh.vim there is variable g:sh_fold_enabled (see header
            of the file) set it to somthing except 0 (e.g let g:sh_fold_enabled=1)
            and use folding Lennart Schultz provided you with. I not often use sh scripts,
            so don't know what it fold out, but try it. Say if it folds not things
            you whant.

            vhn> Thanks
            vhn> Henrik



            --
            Best regards,
            Sonic_Wind mailto:sonic_wind@...
          • drchip@campbellfamily.biz
            ... As a minor footnote, I haven t heard from Lennart Schultz for years. The has changed radically since he was the maintainer, and certainly folding
            Message 5 of 9 , Nov 29, 2004
            • 0 Attachment
              Quoting Sonic_Wind <sonic_wind@...>:

              > In syntax/sh.vim there is variable g:sh_fold_enabled (see header
              > of the file) set it to somthing except 0 (e.g let g:sh_fold_enabled=1)
              > and use folding Lennart Schultz provided you with. I not often use sh
              > scripts,
              > so don't know what it fold out, but try it. Say if it folds not things
              > you whant.

              As a minor footnote, I haven't heard from Lennart Schultz for years.
              The <sh.vim> has changed radically since he was the maintainer, and
              certainly folding wasn't available then.

              FYI,
              Chip Campbell
            • Gary Johnson
              ... I can t get this to work, either. More precisely, the folding of here documents works fine but the folding of functions does not. I tried to isolate the
              Message 6 of 9 , Nov 29, 2004
              • 0 Attachment
                On 2004-11-29, vim@... wrote:
                > On Mon, Nov 29, 2004 at 04:17:40PM +0200, Sonic_Wind wrote:
                > > Hello Henrik,
                > >
                > > Monday, November 29, 2004, 2:35:02 PM, you wrote:
                > >
                > > > Fellow vim users!
                > >
                > > > I am in great need of using function folding, and i have
                > > > tried to enable it
                > > > with the syntax folding, but i can't get it to work.
                > >
                > > > Since there seem to be support for folding in the syntax
                > > > file, cant i just
                > > > enable it by a simple command, like "syntax on" but "folding on"?
                > >
                > > > set foldmethod=syntax and enabling folding does not seem to work.
                > >
                > > > I'm using VIM 6.3...
                > >
                > > > Thanks for any pointers, google was unable to help me ;)
                > >
                > >
                > > set foldmethod=syntax " means that syntax regions will be folded
                > > " the discription of such rigions must contain
                > > " fold key word
                > > for C-like languages this might looks like:
                > > sy region myFold start="{" end="}" fold transparent
                > > , so what language do you use.
                >
                > It's shell scripts .sh files, syntax highlighting works fine. But
                > do i have to define them with start and end if the syntaxfile
                > supports folding, should i not be able to just start the folding?

                I can't get this to work, either. More precisely, the folding of
                "here" documents works fine but the folding of functions does not.
                I tried to isolate the problem to something in my setup, but even a
                minimal configuration still exhibits the problem.

                I created the following test file, syn_test.sh:

                ----------------------------------------------------------------

                cat << EOF > /dev/null
                this
                that
                EOF

                fix_path() {
                some_path=""
                other_path=""
                }

                ----------------------------------------------------------------

                started vim with this command:

                vim -N -u NONE syn_test.sh

                and executed these commands within vim:

                set foldmethod=syntax
                let g:sh_fold_enabled=1
                so $VIMRUNTIME/syntax/sh.vim

                The result was that the four lines of the "here" document were
                folded but the function was not. It looks like a bug in
                syntax/sh.vim to me.

                I am running vim-6.3 on an HP-UX 10.20 system.

                VIM - Vi IMproved 6.3 (2004 June 7, compiled Jun 8 2004 13:44:24)
                Compiled by garyjohn@davinci
                Normal version with X11-Motif GUI. Features included (+) or not (-):
                -arabic +autocmd +balloon_eval +browse +builtin_terms +byte_offset +cindent
                +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
                +cryptv +cscope +dialog_con_gui +diff +digraphs -dnd -ebcdic -emacs_tags +eval
                +ex_extra +extra_search -farsi +file_in_path +find_in_path +folding -footer
                +fork() -gettext -hangul_input -iconv +insert_expand +jumplist -keymap -langmap
                +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession
                +modify_fname +mouse +mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm
                -mouse_netterm +mouse_xterm -multi_byte +multi_lang +netbeans_intg -osfiletype
                +path_extra -perl +postscript +printer -python +quickfix -rightleft -ruby
                +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax
                +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
                +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
                +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
                +X11 +xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save
                system vimrc file: "$VIM/vimrc"
                user vimrc file: "$HOME/.vimrc"
                user exrc file: "$HOME/.exrc"
                system gvimrc file: "$VIM/gvimrc"
                user gvimrc file: "$HOME/.gvimrc"
                system menu file: "$VIMRUNTIME/menu.vim"
                fall-back for $VIM: "/home/garyjohn/src/vim-6.3/share/vim"
                Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MOTIF -I/usr/dt/include -g -O2
                Linking: gcc -L/usr/dt/lib -L/usr/local/lib -o vim -lXext -lXm -lXt -lX11 -lSM -lICE -lcurses

                Gary

                --
                Gary Johnson | Agilent Technologies
                garyjohn@... | Wireless Division
                | Spokane, Washington, USA
              • Sonic_Wind
                Hello Gary, I ve already sent a letter with suggestion how to fix it. But now I have to correct myself. The bug was not there. 4 lines below: line 334: syn
                Message 7 of 9 , Nov 30, 2004
                • 0 Attachment
                  Hello Gary,
                  I've already sent a letter with suggestion how to fix it.
                  But now I have to correct myself. The bug was not there.
                  4 lines below:
                  line 334:
                  syn match bkshFunction "^\s*\<\h\w*\>\s*()" skipwhite skipnl contains=bkshFunctionParen
                  " someone forgoten to add <contained> key word so the pattenr maches
                  "and the start pattern fails to match.

                  Now it looks like this and work:

                  syn match bkshFunction "^\s*\<\h\w*\>\s*()" contained skipwhite skipnl contains=bkshFunctionParen


                  Tuesday, November 30, 2004, 5:11:23 AM, you wrote:

                  GJ> I can't get this to work, either. More precisely, the folding of
                  GJ> "here" documents works fine but the folding of functions does not.
                  GJ> I tried to isolate the problem to something in my setup, but even a
                  GJ> minimal configuration still exhibits the problem.

                  GJ> I created the following test file, syn_test.sh:

                  GJ>
                  GJ> ----------------------------------------------------------------

                  GJ> cat << EOF > /dev/null
                  GJ> this
                  GJ> that
                  GJ> EOF

                  GJ> fix_path() {
                  GJ> some_path=""
                  GJ> other_path=""
                  GJ> }

                  GJ>
                  GJ> ----------------------------------------------------------------

                  GJ> started vim with this command:

                  GJ> vim -N -u NONE syn_test.sh

                  GJ> and executed these commands within vim:

                  GJ> set foldmethod=syntax
                  GJ> let g:sh_fold_enabled=1
                  GJ> so $VIMRUNTIME/syntax/sh.vim

                  GJ> The result was that the four lines of the "here" document were
                  GJ> folded but the function was not. It looks like a bug in
                  GJ> syntax/sh.vim to me.



                  --
                  Best regards,
                  Sonic_Wind mailto:sonic_wind@...
                • Gary Johnson
                  ... That indeed fixed it. Thanks very much! Regards, Gary -- Gary Johnson | Agilent Technologies garyjohn@spk.agilent.com | Wireless
                  Message 8 of 9 , Nov 30, 2004
                  • 0 Attachment
                    On 2004-11-30, Sonic_Wind <sonic_wind@...> wrote:
                    > Hello Gary,
                    > I've already sent a letter with suggestion how to fix it.
                    > But now I have to correct myself. The bug was not there.
                    > 4 lines below:
                    > line 334:
                    > syn match bkshFunction "^\s*\<\h\w*\>\s*()" skipwhite skipnl contains=bkshFunctionParen
                    > " someone forgoten to add <contained> key word so the pattenr maches
                    > "and the start pattern fails to match.
                    >
                    > Now it looks like this and work:
                    >
                    > syn match bkshFunction "^\s*\<\h\w*\>\s*()" contained skipwhite skipnl contains=bkshFunctionParen

                    That indeed fixed it. Thanks very much!

                    Regards,
                    Gary

                    --
                    Gary Johnson | Agilent Technologies
                    garyjohn@... | Wireless Division
                    | Spokane, Washington, USA
                  • Henrik Johansson
                    On 2004-11-30, at 04.11, Gary Johnson wrote: ... Ok, appart from the function folding bug i can get it to work now, i think that enabling syntaxfolding
                    Message 9 of 9 , Nov 30, 2004
                    • 0 Attachment
                      On 2004-11-30, at 04.11, Gary Johnson wrote:

                      <snip>

                      >
                      > started vim with this command:
                      >
                      > vim -N -u NONE syn_test.sh
                      >
                      > and executed these commands within vim:
                      >
                      > set foldmethod=syntax
                      > let g:sh_fold_enabled=1
                      > so $VIMRUNTIME/syntax/sh.vim

                      Ok, appart from the function folding bug i can get it to work now, i
                      think that enabling syntaxfolding should be as simple as enabling
                      indentfolding, just setting set foldmethod=syntax in your vimrc file
                      should give you folding for all syntaxes that supports it.

                      The other two step should not be necessary, should they?

                      Just a thought, i'm not questioning you Gary ;)

                      Regards
                      Henrik
                    Your message has been successfully submitted and would be delivered to recipients shortly.