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

Returning to same line

Expand Messages
  • Michael Keightley
    When I start the version of Vim that comes with Red Hat 7.X or 8.0, the cursor is placed on the same line as when I lasted edited the file. I ve compiled up
    Message 1 of 5 , Nov 27, 2002
    • 0 Attachment
      When I start the version of Vim that comes with Red Hat 7.X or 8.0, the cursor
      is placed on the same line as when I lasted edited the file. I've compiled up
      Vim 6.1 or Red Hat 7.1 and Solaris 2.6, but I don't get this behaviour. The
      cursor is always at the top of the file when I start Vim. My .vimrc is the
      same in both cases. Is this a compile time option, or is there something in
      /usr/share/vim on Red Hat that does this?

      Michael
      --
      Michael Keightley <Michael.Keightley@...> Tel: +44 131 220 4491
      Systems Manager, Quadstone Limited, Fax: +44 131 220 4492
      16 Chester Street, Edinburgh EH3 7RA, Scotland http://www.quadstone.com
    • Benji Fisher
      ... The output of ... will tell you where the system vimrc is. RH supplies a very old system vimrc file; I really wish they would scrap it. Have a look at
      Message 2 of 5 , Nov 27, 2002
      • 0 Attachment
        Michael Keightley wrote:
        > When I start the version of Vim that comes with Red Hat 7.X or 8.0, the cursor
        > is placed on the same line as when I lasted edited the file. I've compiled up
        > Vim 6.1 or Red Hat 7.1 and Solaris 2.6, but I don't get this behaviour. The
        > cursor is always at the top of the file when I start Vim. My .vimrc is the
        > same in both cases. Is this a compile time option, or is there something in
        > /usr/share/vim on Red Hat that does this?
        >
        > Michael

        The output of

        :version

        will tell you where the system vimrc is. RH supplies a very old system
        vimrc file; I really wish they would scrap it. Have a look at
        [g]vimrc_example.vim in the standard distribution; they are much more
        recent, and include the feature you mention.

        HTH --Benji Fisher
      • Bram Moolenaar
        ... This must be something in the Red Hat startup script. Look for the system vimrc file line in the output of the :version command. This is what I use
        Message 3 of 5 , Dec 31, 2002
        • 0 Attachment
          Michael Keightley wrote:

          > When I start the version of Vim that comes with Red Hat 7.X or 8.0,
          > the cursor is placed on the same line as when I lasted edited the
          > file. I've compiled up Vim 6.1 or Red Hat 7.1 and Solaris 2.6, but I
          > don't get this behaviour. The cursor is always at the top of the file
          > when I start Vim. My .vimrc is the same in both cases. Is this a
          > compile time option, or is there something in /usr/share/vim on Red
          > Hat that does this?

          This must be something in the Red Hat startup script. Look for the
          "system vimrc file" line in the output of the ":version" command.

          This is what I use myself:

          " When editing a file, always jump to the last known cursor position.
          autocmd BufReadPost *
          \ if line("'\"") > 0 && line("'\"") <= line("$") |
          \ exe "normal g`\"" |
          \ let b:doopenfold = 1 |
          \ endif
          " Need to postpone using "zv" until after reading the modelines.
          autocmd BufWinEnter *
          \ if exists("b:doopenfold") |
          \ unlet b:doopenfold |
          \ exe "normal zv" |
          \ endif

          --
          hundred-and-one symptoms of being an internet addict:
          261. You find diskettes in your pockets when doing laundry.

          /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
          /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
          \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
          \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
        • Antoine J. Mechelynck
          ... [...] Couldn t it just be the f or suboption in the viminfo option? (see :help viminfo ) If f is absent or nonzero, then marks, *including cursor
          Message 4 of 5 , Jan 1, 2003
          • 0 Attachment
            Bram Moolenaar <Bram@...> wrote:
            > Michael Keightley wrote:
            >
            > > When I start the version of Vim that comes with Red Hat 7.X or 8.0,
            > > the cursor is placed on the same line as when I lasted edited the
            > > file. I've compiled up Vim 6.1 or Red Hat 7.1 and Solaris 2.6, but I
            > > don't get this behaviour. The cursor is always at the top of the file
            > > when I start Vim. My .vimrc is the same in both cases. Is this a
            > > compile time option, or is there something in /usr/share/vim on Red
            > > Hat that does this?
            >
            > This must be something in the Red Hat startup script. Look for the
            > "system vimrc file" line in the output of the ":version" command.
            >
            [...]

            Couldn't it just be the f or ' suboption in the 'viminfo' option? (see :help
            'viminfo') If f is absent or nonzero, then marks, *including cursor
            position,* are saved for all files. If present and zero, marks and cursor
            position are not saved. The number of files for which marks (and cursor
            position) are remembered is set by the ' (apostrophe) suboption. Check it
            with :set viminfo?, check where it was set (latest) by :verbose set viminfo?

            HTH,
            Tony.
          • David Fishburn
            Ahh, that is exactly what I have wanted... Thanks, Bram! ... From: Bram@moolenaar.net [mailto:Bram@moolenaar.net] This is what I use myself: When editing a
            Message 5 of 5 , Jan 2, 2003
            • 0 Attachment
              Ahh, that is exactly what I have wanted...

              Thanks, Bram!

              -----Original Message-----
              From: Bram@... [mailto:Bram@...]

              This is what I use myself:

              " When editing a file, always jump to the last known cursor position.
              autocmd BufReadPost *
              \ if line("'\"") > 0 && line("'\"") <= line("$") |
              \ exe "normal g`\"" |
              \ let b:doopenfold = 1 |
              \ endif
              " Need to postpone using "zv" until after reading the modelines.
              autocmd BufWinEnter *
              \ if exists("b:doopenfold") |
              \ unlet b:doopenfold |
              \ exe "normal zv" |
              \ endif
            Your message has been successfully submitted and would be delivered to recipients shortly.