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

Re: Any way to put tabs in foldtext?

Expand Messages
  • Luc Hermitte
    Hello, ... You can substitute leading tabs by as many strings of &tabstop spaces. That is what I use into:
    Message 1 of 7 , Feb 1, 2005
      Hello,

      * On Tue, Feb 01, 2005 at 03:05:03PM -0700, Bryce Ready <bryce.ready@...> wrote:
      > I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
      > documentation for the foldtext variable (which defines what is shown
      > for a folded group of lines) says that any tabs are converted into
      > spaces. Myself, I prefer to just show the first line as it is (tabs
      > and all), and use the foldcolumn option to tell if there is a fold or
      > not. Is there any workaround that anyone knows of that would allow me
      > to do this?


      You can substitute leading tabs by as many strings of &tabstop spaces.

      That is what I use into:
      http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim

      HTH,

      --
      Luc Hermitte
      http://hermitte.free.fr/vim/
    • Gary Johnson
      ... FWIW, I do something similar in my .vimrc: set foldtext=MyFoldText() MyFoldText() This is intended to be the same as the default foldtext()
      Message 2 of 7 , Feb 1, 2005
        On 2005-02-01, Luc Hermitte <hermitte@...> wrote:
        > Hello,
        >
        > * On Tue, Feb 01, 2005 at 03:05:03PM -0700, Bryce Ready <bryce.ready@...> wrote:
        > > I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
        > > documentation for the foldtext variable (which defines what is shown
        > > for a folded group of lines) says that any tabs are converted into
        > > spaces. Myself, I prefer to just show the first line as it is (tabs
        > > and all), and use the foldcolumn option to tell if there is a fold or
        > > not. Is there any workaround that anyone knows of that would allow me
        > > to do this?
        >
        >
        > You can substitute leading tabs by as many strings of &tabstop spaces.
        >
        > That is what I use into:
        > http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim

        FWIW, I do something similar in my .vimrc:

        set foldtext=MyFoldText()

        " MyFoldText()
        "
        " This is intended to be the same as the default foldtext()
        " function, but without the text of the first line of the fold,
        " since my fold strategy is different from Bram's. See fold.c
        " for a good example of how Bram uses folding. (foldtext will
        " have to be reset to foldtext().) See f_foldtext() in eval.c
        " to see how string is built.
        "
        " Modified 28 Nov. 2001 to indent the fold text by the same
        " amount as the first line of the fold.
        "
        function! MyFoldText()
        let n = v:foldend - v:foldstart + 1
        let i = indent(v:foldstart)
        let istr = ''
        while i > 0
        let istr = istr . ' '
        let i = i - 1
        endwhile
        return istr . "+-" . v:folddashes . " " . n . " lines "
        endfunction

        HTH,
        Gary

        --
        Gary Johnson | Agilent Technologies
        garyjohn@... | Wireless Division
        | Spokane, Washington, USA
      • Raja Koduru
        Luc Hi, Please suggest on how to use this script. or methods to verify if this really loaded by vim and is working. Is there any help which i should be reading
        Message 3 of 7 , Feb 1, 2005
          Luc Hi,
          Please suggest on how to use this script. or methods to verify if this
          really loaded by vim and is working.

          Is there any help which i should be reading first ?

          regards,
          raja koduru


          Luc Hermitte wrote:
          > Hello,
          >
          > * On Tue, Feb 01, 2005 at 03:05:03PM -0700, Bryce Ready <bryce.ready@...> wrote:
          >
          >> I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
          >>documentation for the foldtext variable (which defines what is shown
          >>for a folded group of lines) says that any tabs are converted into
          >>spaces. Myself, I prefer to just show the first line as it is (tabs
          >>and all), and use the foldcolumn option to tell if there is a fold or
          >>not. Is there any workaround that anyone knows of that would allow me
          >>to do this?
          >
          >
          >
          > You can substitute leading tabs by as many strings of &tabstop spaces.
          >
          > That is what I use into:
          > http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim
          >
          > HTH,
          >
        • Luc Hermitte
          ... This script is a fold plugin for C and C++. It defines two functions used in foldexpr and in foldtext . It is loaded from my .vimrc (available on my
          Message 4 of 7 , Feb 2, 2005
            * On Wed, Feb 02, 2005 at 08:25:02AM +0530, Raja Koduru <kscraja@...> wrote:
            > > > I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
            > > > documentation for the foldtext variable (which defines what is
            > > > shown for a folded group of lines) says that any tabs are
            > > > converted into spaces. Myself, I prefer to just show the first
            > > > line as it is (tabs and all), and use the foldcolumn option to
            > > > tell if there is a fold or not. Is there any workaround that
            > > > anyone knows of that would allow me to do this?
            > >
            > > You can substitute leading tabs by as many strings of &tabstop spaces.
            > > That is what I use into:
            > > http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim

            > Please suggest on how to use this script. or methods to verify if this
            > really loaded by vim and is working.

            This script is a fold plugin for C and C++. It defines two functions
            used in 'foldexpr' and in 'foldtext'.

            It is loaded from my .vimrc (available on my site) thanks to a few
            autocommands very similar to the ones used to load ftplugins.
            It should be droppable as it is into {rtp}/ftplugin/c/, and get loaded
            automatically for C and C++ files.

            > Is there any help which i should be reading first ?

            May be
            :h fold.txt
            ?



            --
            Luc Hermitte
            http://hermitte.free.fr/vim/
          • Raja Koduru
            ... Luc, When i enable these fold-scripts, the file loading is taking 4 to 6 seconds for a file of size 557 lines. This load time is even worse for larger
            Message 5 of 7 , Feb 4, 2005
              Luc Hermitte wrote:
              > * On Wed, Feb 02, 2005 at 08:25:02AM +0530, Raja Koduru <kscraja@...> wrote:
              >
              >>>>I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
              >>>>documentation for the foldtext variable (which defines what is
              >>>>shown for a folded group of lines) says that any tabs are
              >>>>converted into spaces. Myself, I prefer to just show the first
              >>>>line as it is (tabs and all), and use the foldcolumn option to
              >>>>tell if there is a fold or not. Is there any workaround that
              >>>>anyone knows of that would allow me to do this?
              >>>
              >>>You can substitute leading tabs by as many strings of &tabstop spaces.
              >>>That is what I use into:le
              >>>http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim
              >
              >
              >>Please suggest on how to use this script. or methods to verify if this
              >>really loaded by vim and is working.
              >
              >
              > This script is a fold plugin for C and C++. It defines two functions
              > used in 'foldexpr' and in 'foldtext'.
              >
              > It is loaded from my .vimrc (available on my site) thanks to a few
              > autocommands very similar to the ones used to load ftplugins.
              > It should be droppable as it is into {rtp}/ftplugin/c/, and get loaded
              > automatically for C and C++ files.
              >
              >
              >>Is there any help which i should be reading first ?
              >
              >
              > May be
              > :h fold.txt
              > ?
              >
              >
              >
              Luc,
              When i enable these fold-scripts, the file loading is taking 4 to 6
              seconds for a file of size 557 lines. This load time is even worse for
              larger files. But when is use ...

              autocmd BufNewFile,BufRead *.[ch],*.cpp syn region myFold start="{"
              end="}" transparent fold

              file loading is not taking much time.Is there anything that I should be
              doing to resolve this. Or is the default load of the scripts. My system
              configuration: P3-1G Hz-256MB Ram-XP

              regards,
              raja koduru
            • Luc Hermitte
              Hello, ... I know. My script is damn slow :-( Unfortunatelly I do not have much time to correctly rewrite it. I only gave you a link to it in the case you
              Message 6 of 7 , Feb 9, 2005
                Hello,

                * On Fri, Feb 04, 2005 at 04:51:15PM +0530, Raja Koduru <kscraja@...> wrote:
                > >>>>I am using gVim 6.3.30, on a Fedora Core 3 linux machine. The
                > >>>>documentation for the foldtext variable (which defines what is
                > >>>>shown for a folded group of lines) says that any tabs are
                > >>>>converted into spaces. Myself, I prefer to just show the first
                > >>>>line as it is (tabs and all), and use the foldcolumn option to
                > >>>>tell if there is a fold or not. Is there any workaround that
                > >>>>anyone knows of that would allow me to do this?
                > >>>
                > >>>You can substitute leading tabs by as many strings of &tabstop
                > >>>spaces. That is what I use into:le
                > >>>http://hermitte.free.fr/vim/ressources/vimfiles/fold/c-fold.vim
                > >
                > >>Please suggest on how to use this script. or methods to verify if this
                > >>really loaded by vim and is working.
                > >
                > >This script is a fold plugin for C and C++. It defines two functions
                > >used in 'foldexpr' and in 'foldtext'.
                > >
                > >It is loaded from my .vimrc (available on my site) thanks to a few
                > >autocommands very similar to the ones used to load ftplugins. It
                > >should be droppable as it is into {rtp}/ftplugin/c/, and get loaded
                > >automatically for C and C++ files.
                > >
                > >
                > Luc,
                > When i enable these fold-scripts, the file loading is taking 4 to 6
                > seconds for a file of size 557 lines. This load time is even worse for
                > larger files. But when is use ...

                I know. My script is damn slow :-(
                Unfortunatelly I do not have much time to correctly rewrite it.
                I only gave you a link to it in the case you could be interrested to
                have your own 'foldtext' function.

                However, I must admit I do not know whether we can set 'foldtext' to a
                custom function and still set 'foldmethod' to something like "syntax".

                Regards

                --
                Luc Hermitte
                http://hermitte.free.fr/vim/
              Your message has been successfully submitted and would be delivered to recipients shortly.