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

Re: New feature: cursor at the beginning of tab character in normal mode

Expand Messages
  • Bram Moolenaar
    ... The way it works is intentional. It s how Vi has always worked. I have no intention to change it. Now we could start a long discussion about yet another
    Message 1 of 10 , Oct 2, 2008
    • 0 Attachment
      Vladimir A. Pavlov wrote:

      > A few days ago I wrote the following to vim@...:
      >
      > > I'd like to switch to vim but there is an annoying issue with
      > > it that I couldn't solve.
      > >
      > > When the cursor is at a tab character most editors display
      > > the cursor at the beginning of the interval the tab character
      > > occupies as follows (_ is the cursor):
      > >
      > > _ if (a > c) ...
      > >
      > > Vim does the same in insert or replace mode. But in normal
      > > mode the cursor is displayed at the end of the tab character:
      > >
      > > _if (a > c) ...
      > >
      > > Is there a way to make vim show the cursor at the beginning
      > > of a tab character in normal mode as it does in insert mode?
      > >
      > > I tried searching in Google but found nothing unfortunatelly :(
      >
      > Then I got a reply that said it's impossible without vim code
      > modification so I decided to find out how to fix that.
      >
      > I seem to find the solution (the patch is at the end of this
      > email) but it is so simple that I can't understand why it hasn't
      > been done yet (since I know several people that are irritated by
      > this "feature" of vim).
      >
      > I guess this mailing list is the best place to ask whether I
      > miss anything. Here are my questions:
      >
      > 1. Are there any obvious problems/bugs with the patch itself?
      > In other words, does it breaks anything very "basic" so
      > that it definitely breaks some basic functionality or
      > some plugins?

      The way it works is intentional. It's how Vi has always worked. I have
      no intention to change it.

      Now we could start a long discussion about yet another option... Keep
      in mind that switching this option on would have the risk of breaking
      some plugins and making users wonder why Vim doesn't behave as expected.

      > 2. If there are no problems with it, do you have any wishes to
      > apply it to the trunk? (And what the reasons for not doing
      > so?)

      I haven't tried it, but I would suspect there are a few more places to
      change.

      > If so, I would add an option called, say, cursorattabstart
      > that will trigger the new behaviour and resend the patch
      > here for anyone of you to commit.

      --
      You cannot have a baby in one month by getting nine women pregnant.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Craig Barkhouse
      Not to take sides, but just to add my comments... 1) In normal mode, if you have the list option on, the cursor is displayed at the beginning of the tab
      Message 2 of 10 , Oct 2, 2008
      • 0 Attachment
        Not to take sides, but just to add my comments...

        1) In normal mode, if you have the 'list' option on, the cursor is displayed at the beginning of the tab character, not the end. So now it's not just mode that determines it. If you sit your cursor on a tab character and repeatedly toggle the 'list' option (which I actually have a keymapping for), the cursor will actually jump back and forth on screen from the beginning of the tab to the end. That seems unexpected to me.

        2) As a general question: If there's a quirk carried forward from original Vi, and the general consensus among Vim users is that the quirk is only there for strict Vi compatibility and it would make more sense to change it, would it not make sense to have it controlled by the 'compatible' option? Setting 'nocompatible' already breaks some Vi compliance. So, yet-another-option would not necessarily need to be introduced.

        Cheers,
        Craig


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Ian Kelling
        ... Think about this. Changing it would be unexpected to the vast majority of vim users. I agree with Bram, this is best left alone. - Ian
        Message 3 of 10 , Oct 3, 2008
        • 0 Attachment
          > That seems unexpected to me.
          > Cheers,
          > Craig

          Think about this. Changing it would be unexpected to the vast majority
          of vim users. I agree with Bram, this is best left alone.

          - Ian
          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Richard Hartmann
          ... Note the second space after the second . I agree with the others that yet another option is overkill. I would suggest adapting the helpfiles to reflect
          Message 4 of 10 , Oct 3, 2008
          • 0 Attachment
            On Thu, Oct 2, 2008 at 23:04, Ingo Karkat <swdev@...> wrote:

            > ':set list listchars=tab:\ \ '

            Note the second space after the second \.

            I agree with the others that yet another option is overkill.
            I would suggest adapting the helpfiles to reflect the above, though.
            Vladimir, I suspect Bram would accept a patch against the help.


            Richard

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Vladimir A. Pavlov
            ... I found the section called VIEWING TABS in the chapter 05.7 of the ... with the explanation what the setting does. However there is no word concerning
            Message 5 of 10 , Oct 6, 2008
            • 0 Attachment
              On Sat, 4 Oct 2008 at 02:37 Richard Hartmann wrote:
              >
              > I would suggest adapting the helpfiles to reflect the above, though.

              I found the section called "VIEWING TABS" in the chapter 05.7 of the
              standard vim manual. It contains the following:

              > :set listchars=tab:>-,trail:-

              with the explanation what the setting does. However there is no
              word concerning cursor position there. That chapter seems to be the
              best place to write how to emulate the "standard" cursor behaviour
              in vim. But:
              1. it would be difficult for a novice who came from another editor
              to find that place and he/she won't probably find the solution of
              the problem. Are there better places?
              2. is the solution in question correct on all platforms/terminals so
              that we are allowed to add such a comment to the help file? It
              works on x86 and x86_64 in xterm and linux terminals but what
              about others?

              > Vladimir, I suspect Bram would accept a patch against the help.

              Bram, would you?

              --
              Vladimir

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Richard Hartmann
              ... Agreed. But havin it _somewhere_ is better than nowhere. ... As this is a UI thing and quite basic, I am willing to bet that it will work everywhere. ...
              Message 6 of 10 , Oct 6, 2008
              • 0 Attachment
                2008/10/6 Vladimir A. Pavlov <pv4@...>:

                > 1. it would be difficult for a novice who came from another editor
                > to find that place and he/she won't probably find the solution of
                > the problem. Are there better places?

                Agreed. But havin it _somewhere_ is better than nowhere.


                > 2. is the solution in question correct on all platforms/terminals so
                > that we are allowed to add such a comment to the help file? It
                > works on x86 and x86_64 in xterm and linux terminals but what
                > about others?

                As this is a UI thing and quite basic, I am willing to bet that it will
                work everywhere.


                > Bram, would you?

                He is on holidays, don't expect a quick answer.
                Richard

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Tony Mechelynck
                ... What about under either or both of :help list and :help listchars instead? Wouldn t that be more discoverable ? (And þese options are referenced
                Message 7 of 10 , Oct 7, 2008
                • 0 Attachment
                  On 06/10/08 21:38, Vladimir A. Pavlov wrote:
                  > On Sat, 4 Oct 2008 at 02:37 Richard Hartmann wrote:
                  >> I would suggest adapting the helpfiles to reflect the above, though.
                  >
                  > I found the section called "VIEWING TABS" in the chapter 05.7 of the
                  > standard vim manual. It contains the following:
                  >
                  >> :set listchars=tab:>-,trail:-
                  >
                  > with the explanation what the setting does. However there is no
                  > word concerning cursor position there. That chapter seems to be the
                  > best place to write how to emulate the "standard" cursor behaviour
                  > in vim. But:
                  > 1. it would be difficult for a novice who came from another editor
                  > to find that place and he/she won't probably find the solution of
                  > the problem. Are there better places?

                  What about under either or both of ":help 'list'" and ":help
                  'listchars'" instead? Wouldn't that be more "discoverable"? (And þese
                  options are referenced from that 05.7 section.)

                  > 2. is the solution in question correct on all platforms/terminals so
                  > that we are allowed to add such a comment to the help file? It
                  > works on x86 and x86_64 in xterm and linux terminals but what
                  > about others?

                  It works the same way in the GTK2 GUI, and I don't see why it wouldn't
                  work the same way in other cases, including not only other Linux GUIs
                  and terminals, but also Windows, Mac, Amiga, VMS, whatever...

                  >
                  >> Vladimir, I suspect Bram would accept a patch against the help.
                  >
                  > Bram, would you?
                  >
                  > --
                  > Vladimir

                  Best regards,
                  Tony.
                  --
                  Please, won't somebody tell me what diddie-wa-diddie means?

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Vladimir A. Pavlov
                  Hi! I made a patch to the documentation to mention the way to display the cursor where most popular editors do. I mention the cursor positioning behaviour in
                  Message 8 of 10 , Nov 2, 2008
                  • 0 Attachment
                    Hi!

                    I made a patch to the documentation to mention the way to
                    display the cursor where most popular editors do.

                    I mention the cursor positioning behaviour in 'list' help node,
                    put the command in question there and made a link from 'listchars'
                    node to 'list' one.

                    I think it's better to put the command in question to 'list'
                    help node since it's 'list' (not, 'listchars') option's issue
                    that allows us to do what we want.

                    P.S. Sorry for being so late, I've been busy this month :(

                    --
                    Vladimir

                    The patch follows (should be applied to just unpacked
                    vim-7.2.tar.bz2):

                    diff -Naur vim72.orig/runtime/doc/options.txt vim72/runtime/doc/options.txt
                    --- vim72.orig/runtime/doc/options.txt 2008-08-09 18:22:59.000000000 +0400
                    +++ vim72/runtime/doc/options.txt 2008-11-02 13:45:41.000000000 +0300
                    @@ -4331,6 +4331,18 @@
                    'wrapmargin') when 'cpoptions' includes 'L'. See 'listchars' for
                    changing the way tabs are displayed.

                    + In Normal mode the cursor is displayed at the end of the space a tab
                    + character occupies. In List mode it's displayed at the beginning of
                    + the space while vim behaves similarly to Normal mode.
                    +
                    + This can be used to make vim display the cursor in Normal mode at the
                    + beginning of the space a tab character occupies as it does in Insert
                    + mode and as other popular text editors do.
                    +
                    + The following command does this: >
                    + :set list lcs=tab:\ \
                    +< Note a space following the second baskslash.
                    +
                    *'listchars'* *'lcs'*
                    'listchars' 'lcs' string (default "eol:$")
                    global
                    @@ -4368,6 +4380,11 @@
                    "precedes". "SpecialKey" for "nbsp", "tab" and "trail".
                    |hl-NonText| |hl-SpecialKey|

                    + Another probable usage for 'lcs' option is to make vim display the
                    + cursor in Normal mode at the beginning of the space a tab character
                    + occupies as it does in Insert mode and as other popular text editors
                    + do. See |'list'| for details.
                    +
                    *'lpl'* *'nolpl'* *'loadplugins'* *'noloadplugins'*
                    'loadplugins' 'lpl' boolean (default on)
                    global


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.