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

VIM scrollbar

Expand Messages
  • Dotan Cohen
    I find it difficult to keep track of my location in a file with information like 351/2343 15%, and would really like a visual indication such as Code Overview
    Message 1 of 13 , Jul 3, 2012
    • 0 Attachment
      I find it difficult to keep track of my location in a file with
      information like 351/2343 15%, and would really like a visual
      indication such as Code Overview but in the terminal:
      http://www.vim.org/scripts/script.php?script_id=2888

      I'm thinking that the next best thing would be a scrollbar. Googling
      for a VIM scrollbar I found this SuperUser (Stack Overflow) question:
      http://superuser.com/questions/276334/scroll-bar-for-vimcurses-based-one-not-gvim

      As there was no good answer, I added a bounty to the question. I know
      that some guys here also post on Stack Overflow so I thought that you
      guys might want that bounty! Even for those who don't use Stack
      Overflow, if you know any good solutions for keeping track of one's
      position in long code files of dubious authorship, then I would love
      to know about it.

      Thanks!

      --
      Dotan Cohen

      http://gibberish.co.il
      http://what-is-what.com

      --
      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
    • Christian Brabandt
      Hi Dotan! ... I used to have this one in my .vimrc (it s based on a tip by A.Politz): https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136 regards,
      Message 2 of 13 , Jul 3, 2012
      • 0 Attachment
        Hi Dotan!

        On Di, 03 Jul 2012, Dotan Cohen wrote:

        > I find it difficult to keep track of my location in a file with
        > information like 351/2343 15%, and would really like a visual
        > indication such as Code Overview but in the terminal:
        > http://www.vim.org/scripts/script.php?script_id=2888
        >
        > I'm thinking that the next best thing would be a scrollbar. Googling
        > for a VIM scrollbar I found this SuperUser (Stack Overflow) question:
        > http://superuser.com/questions/276334/scroll-bar-for-vimcurses-based-one-not-gvim
        >
        > As there was no good answer, I added a bounty to the question. I know
        > that some guys here also post on Stack Overflow so I thought that you
        > guys might want that bounty! Even for those who don't use Stack
        > Overflow, if you know any good solutions for keeping track of one's
        > position in long code files of dubious authorship, then I would love
        > to know about it.

        I used to have this one in my .vimrc (it's based on a tip by A.Politz):
        https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136

        regards,
        Christian
        --

        --
        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
      • ping
        ... I did a quick test but that give me nothing, do I miss anything? put following in .vimrc: A statusbar function, that provides a visual scrollbar
        Message 3 of 13 , Jul 3, 2012
        • 0 Attachment
          >
          > I used to have this one in my .vimrc (it's based on a tip by A.Politz):
          > https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136
          >
          > regards,
          > Christian
          >

          I did a quick test but that give me nothing, do I miss anything?

          " put following in .vimrc:

          " A statusbar function, that provides a visual scrollbar (courtesy of
          A.Politz)
          func! STL()
          let stl = '%f [%{(&fenc==""?&enc:&fenc).((exists("+bomb") &&
          &bomb)?",B":"")}%M%R%H%W] %y [%l/%L,%v] [%p%%]'
          let barWidth = &columns - 65 " <-- wild guess
          let barWidth = barWidth < 3 ? 3 : barWidth

          if line('$') > 1
          let progress = (line('.')-1) * (barWidth-1) / (line('$')-1)
          else
          let progress = barWidth/2
          endif

          " line + vcol + %
          let pad = strlen(line('$'))-strlen(line('.')) + 3 -
          strlen(virtcol('.')) + 3 - strlen(line('.')*100/line('$'))
          let bar = repeat(' ',pad).' [%1*%'.barWidth.'.'.barWidth.'('
          \.repeat('-',progress )
          \.'%2*0%1*'
          \.repeat('-',barWidth - progress - 1).'%0*%)%<]'

          return stl.bar
          endfun

          hi def link User1 DiffAdd
          hi def link User2 DiffDelete
          set stl=%!STL()

          --
          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
        • Christian Brabandt
          Hi ping! ... Check your laststatus setting. regards, Christian -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply
          Message 4 of 13 , Jul 3, 2012
          • 0 Attachment
            Hi ping!

            On Di, 03 Jul 2012, ping wrote:

            > I did a quick test but that give me nothing, do I miss anything?

            Check your 'laststatus' setting.

            regards,
            Christian
            --

            --
            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
          • ping
            you are right Christian. it s laststatus (my value was def 1) now I see the effect of the code. thanks! regards ping ... -- You received this message from
            Message 5 of 13 , Jul 3, 2012
            • 0 Attachment
              you are right Christian. it's 'laststatus' (my value was def 1)
              now I see the effect of the code.
              thanks!

              regards
              ping

              On 07/03/2012 04:48 PM, Christian Brabandt wrote:
              > Hi ping!
              >
              > On Di, 03 Jul 2012, ping wrote:
              >
              >> I did a quick test but that give me nothing, do I miss anything?
              >
              > Check your 'laststatus' setting.
              >
              > regards,
              > Christian
              >

              --
              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
            • Dotan Cohen
              ... Thank you Christian, this is great! In the status bar it takes up no additional screen space either. There is a ton of stuff that I don t understand in
              Message 6 of 13 , Jul 3, 2012
              • 0 Attachment
                On Tue, Jul 3, 2012 at 9:35 PM, Christian Brabandt <cblists@...> wrote:
                > I used to have this one in my .vimrc (it's based on a tip by A.Politz):
                > https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136
                >

                Thank you Christian, this is great! In the status bar it takes up no
                additional screen space either. There is a ton of stuff that I don't
                understand in there, so I'll see what I can decipher with VIM help. If
                you are on Stack Overflow or Super User you might want to post that as
                an answer.

                I'm still holding out for marks in the statusbar, I will try to see if
                I can add them myself. Three questions that might get me on my way:
                1) For mark 'n' how might I find which line it is on, i.e. get a variable nLine?
                2) Assuming a string 'bar', how might I read an arbitrary character in
                that string?
                3) Assuming a string 'bar', how might I replace an arbitrary character
                in that string?

                I read through ':h functions' and for (2) I thought that get() would
                work, but it doesn't. And for (3) I was hoping for a put() function
                but there is none. Is there something that I'm missing or should I
                write my own helper functions for this?

                Thanks!

                --
                Dotan Cohen

                http://gibberish.co.il
                http://what-is-what.com

                --
                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
              • Christian Brabandt
                Hi Dotan! ... I only very seldomly post there, but I ll do it this time. I ll probably also add some kind of vertical scrollbar into my DynamicSigns plugin.
                Message 7 of 13 , Jul 4, 2012
                • 0 Attachment
                  Hi Dotan!

                  On Mi, 04 Jul 2012, Dotan Cohen wrote:

                  > On Tue, Jul 3, 2012 at 9:35 PM, Christian Brabandt <cblists@...> wrote:
                  > > I used to have this one in my .vimrc (it's based on a tip by A.Politz):
                  > > https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136
                  > >
                  >
                  > Thank you Christian, this is great! In the status bar it takes up no
                  > additional screen space either. There is a ton of stuff that I don't
                  > understand in there, so I'll see what I can decipher with VIM help. If
                  > you are on Stack Overflow or Super User you might want to post that as
                  > an answer.

                  I only very seldomly post there, but I'll do it this time. I'll probably
                  also add some kind of vertical scrollbar into my DynamicSigns plugin.

                  > I'm still holding out for marks in the statusbar, I will try to see if
                  > I can add them myself. Three questions that might get me on my way:
                  > 1) For mark 'n' how might I find which line it is on, i.e. get a variable nLine?

                  :h getpos()

                  > 2) Assuming a string 'bar', how might I read an arbitrary character in
                  > that string?

                  Possibly using one of the match-functions or using indexing like
                  "bar"[2]

                  :h expr8
                  :h match()

                  > 3) Assuming a string 'bar', how might I replace an arbitrary character
                  > in that string?

                  :h substitute()


                  Mit freundlichen Grüßen
                  Christian
                  --
                  Ein Mann ist alt, wenn er morgens ohne einen Wunsch aufwacht.
                  -- Enzo Ferrari

                  --
                  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
                • Dotan Cohen
                  ... Then the bounty will help! I ll take a look at the DynamicSigns plugin, the name sounds useful. ... Thank you, it looks like those are all the critical
                  Message 8 of 13 , Jul 4, 2012
                  • 0 Attachment
                    On Wed, Jul 4, 2012 at 10:37 AM, Christian Brabandt <cblists@...> wrote:
                    > I only very seldomly post there, but I'll do it this time. I'll probably
                    > also add some kind of vertical scrollbar into my DynamicSigns plugin.
                    >

                    Then the bounty will help! I'll take a look at the DynamicSigns
                    plugin, the name sounds useful.


                    >> I'm still holding out for marks in the statusbar, I will try to see if
                    >> I can add them myself. Three questions that might get me on my way:
                    >> 1) For mark 'n' how might I find which line it is on, i.e. get a variable nLine?
                    >
                    > :h getpos()
                    >
                    > Possibly using one of the match-functions or using indexing like
                    > "bar"[2]
                    >
                    > :h expr8
                    > :h match()
                    >
                    > :h substitute()
                    >

                    Thank you, it looks like those are all the critical pieces. When I get
                    something working I'll post it.


                    > Mit freundlichen Grüßen
                    > Christian

                    Danke Jungs!

                    --
                    Dotan Cohen

                    http://gibberish.co.il
                    http://what-is-what.com

                    --
                    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
                  • Christian Brabandt
                    Hi ... The development version of DynamicSigns now also contains a Sign-Scrollbar. You can find it here: https://github.com/chrisbra/DynamicSigns regards,
                    Message 9 of 13 , Jul 8, 2012
                    • 0 Attachment
                      Hi

                      On Mi, 04 Jul 2012, Christian Brabandt wrote:

                      > Hi Dotan!
                      >
                      > On Mi, 04 Jul 2012, Dotan Cohen wrote:
                      >
                      > > On Tue, Jul 3, 2012 at 9:35 PM, Christian Brabandt <cblists@...> wrote:
                      > > > I used to have this one in my .vimrc (it's based on a tip by A.Politz):
                      > > > https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136
                      > > >
                      > >
                      > > Thank you Christian, this is great! In the status bar it takes up no
                      > > additional screen space either. There is a ton of stuff that I don't
                      > > understand in there, so I'll see what I can decipher with VIM help. If
                      > > you are on Stack Overflow or Super User you might want to post that as
                      > > an answer.
                      >
                      > I only very seldomly post there, but I'll do it this time. I'll probably
                      > also add some kind of vertical scrollbar into my DynamicSigns plugin.

                      The development version of DynamicSigns now also contains a
                      Sign-Scrollbar. You can find it here:
                      https://github.com/chrisbra/DynamicSigns

                      regards,
                      Christian

                      --
                      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
                    • Dotan Cohen
                      On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt ... Thanks Christian! I notice that the plugin has a makefile, but I found no vimball. Is it alright then to
                      Message 10 of 13 , Jul 8, 2012
                      • 0 Attachment
                        On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt
                        > The development version of DynamicSigns now also contains a
                        > Sign-Scrollbar. You can find it here:
                        > https://github.com/chrisbra/DynamicSigns
                        >

                        Thanks Christian! I notice that the plugin has a makefile, but I found
                        no vimball. Is it alright then to just import it all into the proper
                        VIM directories? I don't use Pathogen or any such VIM package
                        managers.


                        --
                        Dotan Cohen

                        http://gibberish.co.il
                        http://what-is-what.com

                        --
                        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
                      • Dotan Cohen
                        ... Thank you, I installed the version from Git. I ve noticed that in DOS-formatted files there are some issues. Each line has an M, even those without mixed
                        Message 11 of 13 , Jul 9, 2012
                        • 0 Attachment
                          On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt <cblists@...> wrote:
                          > The development version of DynamicSigns now also contains a
                          > Sign-Scrollbar. You can find it here:
                          > https://github.com/chrisbra/DynamicSigns
                          >

                          Thank you, I installed the version from Git. I've noticed that in
                          DOS-formatted files there are some issues. Each line has an M, even
                          those without mixed indentation. Signs_Diff doesn't seem to work,
                          either. Signs_Bookmarks does, though. If you want I can send to you a
                          test file.

                          Also, how does one configure the plugin to start when opening a file?
                          I must type :Signs every time I open a file. Adding ":Signs" or
                          "Signs" to .vimrc does not start the pluging automatically (In fact,
                          VIM complains that it is not a command when in .vimrc). Also, I don't
                          see the status bar added.

                          Additionally, I notice that changes are not automatic, rather after
                          each line change one must run :UpdateSigns to have them updated. Might
                          it not be better to do this whenever the user leaves Insert mode or
                          adds a sign?

                          I'm not complaining, but letting you know what I've experienced. I
                          like the fact that I can now see marks and I can use the statusbar
                          code that you mentioned earlier.

                          Thank you!

                          --
                          Dotan Cohen

                          http://gibberish.co.il
                          http://what-is-what.com

                          --
                          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
                        • Christian Brabandt
                          ... Please send me the testfile. And please tell me, what exactly you did. Possibly I need to update the documentation. ... I didn t add the statusbar code, I
                          Message 12 of 13 , Jul 9, 2012
                          • 0 Attachment
                            On Mon, July 9, 2012 14:55, Dotan Cohen wrote:
                            > On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt <cblists@...>
                            > wrote:
                            >> The development version of DynamicSigns now also contains a
                            >> Sign-Scrollbar. You can find it here:
                            >> https://github.com/chrisbra/DynamicSigns
                            >>
                            >
                            > Thank you, I installed the version from Git. I've noticed that in
                            > DOS-formatted files there are some issues. Each line has an M, even
                            > those without mixed indentation. Signs_Diff doesn't seem to work,
                            > either. Signs_Bookmarks does, though. If you want I can send to you a
                            > test file.

                            Please send me the testfile. And please tell me, what exactly you did.
                            Possibly I need to update the documentation.

                            > Also, how does one configure the plugin to start when opening a file?
                            > I must type :Signs every time I open a file. Adding ":Signs" or
                            > "Signs" to .vimrc does not start the pluging automatically (In fact,
                            > VIM complains that it is not a command when in .vimrc). Also, I don't
                            > see the status bar added.

                            I didn't add the statusbar code, I posted earlier, but use signs to draw
                            a ascii scrollbar.

                            > Additionally, I notice that changes are not automatic, rather after
                            > each line change one must run :UpdateSigns to have them updated. Might
                            > it not be better to do this whenever the user leaves Insert mode or
                            > adds a sign?

                            It should update the signs when leaving insert mode and after writing
                            the file.

                            > I'm not complaining, but letting you know what I've experienced. I
                            > like the fact that I can now see marks and I can use the statusbar
                            > code that you mentioned earlier.

                            Thanks for the feedback. I am very grateful for it. Feel free, to
                            contact me privately about any issues you have (I think the list
                            is not the right forum for discussing my plugin).


                            regards,
                            Christian

                            --
                            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
                          • ping
                            more test results: I used to have this and like it: config 1: set statusline=%F%m%r%h%w [FORMAT=%{&ff}] [TYPE=%Y] [ASCII= %03.3b] [HEX= %02.2B]
                            Message 13 of 13 , Jul 9, 2012
                            • 0 Attachment
                              more test results:

                              I used to have this and like it:

                              "config 1:
                              set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\
                              [HEX=\%02.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]

                              now to add the statusline bar, I put following right *under* above line

                              "config 2
                              func! STL()
                              let stl = '%f [%{(&fenc==""?&enc:&fenc).((exists("+bomb") &&
                              &bomb)?",B":"")}%M%R%H%W] %y [%l/%L,%v] [%p%%]'
                              let barWidth = &columns - 65 " <-- wild guess
                              let barWidth = barWidth < 3 ? 3 : barWidth

                              if line('$') > 1
                              let progress = (line('.')-1) * (barWidth-1) / (line('$')-1)
                              else
                              let progress = barWidth/2
                              endif

                              " line + vcol + %
                              let pad = strlen(line('$'))-strlen(line('.')) + 3 -
                              strlen(virtcol('.')) + 3 - strlen(line('.')*100/line('$'))
                              let bar = repeat(' ',pad).' [%1*%'.barWidth.'.'.barWidth.'('
                              \.repeat('-',progress )
                              \.'%2*0%1*'
                              \.repeat('-',barWidth - progress - 1).'%0*%)%<]'

                              return stl.bar
                              endfun

                              hi def link User1 DiffAdd
                              hi def link User2 DiffDelete
                              set stl=%!STL()


                              I know the stl now got reset, but when I test it, I find:
                              previous info retrieved from config1 is still there (most part) in the
                              left, and my new stl bar is also there in the right, which is nice.
                              but the issue is:
                              I seems lost a bit info from config 1:
                              //originally with config1:
                              [0,0005] [66%] [LEN=15] ~/.vimrc [FORMAT=unix] [TYPE=VIM] [ASCII=032]
                              [HEX=20] [POS=0367,0001] [34%] [LEN=1056]

                              //now with addition of config2:
                              RLI-12720.txt_VOOM27 [utf-8,-] [voomtree> RLI-12720.txt [utf-8]
                              [asciidoc2] [2151/2952,1] [72%]
                              [----------------------------------------------------------------------------------------------------0-->

                              so the issue is,
                              1) I lost a small piece of info (the # of lines) of my original stl info,
                              2) currently my bar works only for the 1st 75% part of the file. as you
                              can see from above.

                              how to combile the 2? --- just use the space left by my original stl
                              config in the right side for the new bar config, but without trunking my
                              original info?

                              thanks!

                              > I used to have this one in my .vimrc (it's based on a tip by A.Politz):
                              > https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136
                              >
                              > regards,
                              > Christian
                              >

                              --
                              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.