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

Re: vimdiff usage

Expand Messages
  • Stephane Huaulme
    I should rephrase: if I had a few lines, then the diff is udpating on the screen as I would expect, but it s all considered one chunk, so when I use dp or do,
    Message 1 of 10 , Oct 1, 2002
    • 0 Attachment
      I should rephrase:
      if I had a few lines, then the diff is udpating on the screen as I
      would expect, but it's all considered one chunk, so when I use dp or
      do, it includes the lines I added and I loose the lines I was trying to
      save.

      when I use the :diffu, then I get funky results.

      also, undo is behaving in a strange way, is there another command to
      undo a dp or do?

      thanks

      stephane


      On Tuesday, October 1, 2002, at 09:35 AM, Stephane Huaulme wrote:

      > I'm a bit confused as to how to use vimdiff, in particular, when I
      > want to merge both files. For example, if I have:
      >
      >
      > this is the text this is the text
      > old line 2 new line 2
      > -----------------------------------------next to line 2
      >
      > yet another line yet another line
      >
      > if I move to the right window and add a line where "new line 2" is,
      > things get pretty confused, even after a diffu. What's the normal way
      > to end up with this:
      >
      > this is the text this is the text
      > old line 2 old line 2
      > -----------------------------------------new line 2
      > -----------------------------------------next to line 2
      >
      > yet another line yet another line
      >
      >
      > thanks
      >
      > if there is a better tutorial on how to use vimdiff somewhere (better
      > than :he diff), let me know.
      >
      > thanks
      >
      > stephane
      >
    • Bram Moolenaar
      ... There is no specific command to do these things. Just use Y in one window and p in the other. The diff commands do and dp only take care of moving
      Message 2 of 10 , Oct 1, 2002
      • 0 Attachment
        Stephane Huaulme wrote:

        > I'm a bit confused as to how to use vimdiff, in particular, when I want
        > to merge both files. For example, if I have:
        >
        >
        > this is the text this is the text
        > old line 2 new line 2
        > -----------------------------------------next to line 2
        >
        > yet another line yet another line
        >
        > if I move to the right window and add a line where "new line 2" is,
        > things get pretty confused, even after a diffu. What's the normal way
        > to end up with this:
        >
        > this is the text this is the text
        > old line 2 old line 2
        > -----------------------------------------new line 2
        > -----------------------------------------next to line 2
        >
        > yet another line yet another line


        There is no specific command to do these things. Just use "Y" in one
        window and "p" in the other.

        The diff commands "do" and "dp" only take care of moving lines from one
        file to another, thus making one version equal to the other for a range
        of lines. Merging is ambiguous, specifying what needs to be done would
        be more work than doing it manually.

        --
        From "know your smileys":
        :'-D Laughing so much that they're crying

        /// 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 ///
      • Mark Volkmann
        I m just learning how to use vimdiff to find the difference between two files. I know there are many ways to start it. I m interested in using it after I
        Message 3 of 10 , Sep 30, 2005
        • 0 Attachment
          I'm just learning how to use vimdiff to find the difference between
          two files. I know there are many ways to start it. I'm interested in
          using it after I already have vim running. Here's what I did.

          - open first file
          - ":sp" to split the window
          - open second file in second window
          - ":diffthis" in both buffers
          - "]c" to move to next difference
          - "[c" to move to previous difference

          That seemed to work fine. Then I wanted to turn it off, so I did this.

          - ":set nodiff" in both buffers
          - ":set noscrollbind" in both buffers

          Is there an easier way to set it up or turn it off?

          --
          R. Mark Volkmann
          Partner, Object Computing, Inc.
        • Gary Johnson
          ... - open first file - :diffsplit I prefer - :vert diffsplit as the second step myself. ... I think there may
          Message 4 of 10 , Sep 30, 2005
          • 0 Attachment
            On 2005-09-30, Mark Volkmann <r.mark.volkmann@...> wrote:
            > I'm just learning how to use vimdiff to find the difference between
            > two files. I know there are many ways to start it. I'm interested in
            > using it after I already have vim running. Here's what I did.
            >
            > - open first file
            > - ":sp" to split the window
            > - open second file in second window
            > - ":diffthis" in both buffers
            > - "]c" to move to next difference
            > - "[c" to move to previous difference
            >
            > That seemed to work fine. Then I wanted to turn it off, so I did this.
            >
            > - ":set nodiff" in both buffers
            > - ":set noscrollbind" in both buffers
            >
            > Is there an easier way to set it up ...

            - open first file
            - ":diffsplit" <name of second file>

            I prefer

            - ":vert diffsplit" <name of second file>

            as the second step myself.

            > ...or turn it off?

            I think there may be in vim 7, but not vim 6. Here's what I have in
            my .vimrc:

            -----------------------------------------------------------------
            " Reset everything set by the diff mode.
            " (See ":help diff".)
            "
            if v:version >= 602
            command! -bar -bang Nodiff wincmd l <bar> only<bang> <bar> set nodiff noscrollbind scrollopt-=hor wrap foldcolumn=0 virtualedit=
            else
            command! -bar Nodiff exe 'wincmd l' <bar> only <bar> set nodiff noscrollbind wrap foldcolumn=0 scrollopt-=hor virtualedit=
            endif

            " Set virtualedit=all whenever diff mode is entered.
            "
            au FilterWritePre * if &diff | set virtualedit=all | endif
            -----------------------------------------------------------------

            HTH,
            Gary

            --
            Gary Johnson | Agilent Technologies
            garyjohn@... | Wireless Division
            | Spokane, Washington, USA
          • Yegappan Lakshmanan
            ... The :diffoff command resets the relevant options to their default value. This may be different from what the values were before diff mode was started,
            Message 5 of 10 , Sep 30, 2005
            • 0 Attachment
              On 9/30/05, Gary Johnson <garyjohn@...> wrote:
              > On 2005-09-30, Mark Volkmann <r.mark.volkmann@...> wrote:
              >
              > > ...or turn it off?
              >
              > I think there may be in vim 7, but not vim 6. Here's what I have in
              > my .vimrc:
              >

              In Vim7, you can use the ":diffoff" command. From the Vim help:

              :diffoff Switch off diff mode for the current window.

              :diffoff! Switch off diff mode for all windows.

              The ":diffoff" command resets the relevant options to their default value.
              This may be different from what the values were before diff mode was started,
              the old values are not remembered.

              'diff' off
              'scrollbind' off
              'scrollopt' without "hor"
              'wrap' on
              'foldmethod' "manual"
              'foldcolumn' 0

              - Yegappan
            • Keith W. Roberts
              ... From: Mark Volkmann [mailto:r.mark.volkmann@gmail.com] Sent: Friday, September 30, 2005 3:40 PM To: vim@vim.org Subject: vimdiff usage ... I just use the
              Message 6 of 10 , Oct 2, 2005
              • 0 Attachment
                ----Original Message----
                From: Mark Volkmann [mailto:r.mark.volkmann@...]
                Sent: Friday, September 30, 2005 3:40 PM
                To: vim@...
                Subject: vimdiff usage

                > I'm just learning how to use vimdiff to find the difference between
                > two files. I know there are many ways to start it. I'm interested in
                > using it after I already have vim running. Here's what I did.
                >
                > - open first file
                > - ":sp" to split the window
                > - open second file in second window
                > - ":diffthis" in both buffers
                > - "]c" to move to next difference
                > - "[c" to move to previous difference
                >
                > That seemed to work fine. Then I wanted to turn it off, so I did this.
                >
                > - ":set nodiff" in both buffers
                > - ":set noscrollbind" in both buffers
                >
                > Is there an easier way to set it up or turn it off?

                I just use the following:

                " un-diff the current buffer/window
                noremap ,nd :set nodiff fdc=0 \| norm zR<CR>

                I don't care if the folds stay there; I just don't want to see 'em. And if
                I do :set fdc=2 they become visible again; sometimes handy.

                For multiple windows:

                :windo :norm ,nd

                -Keith
              • David Fishburn
                ... You have had some good responses, I will just show you what I do. In my virmce, I have the MyDiff function. I put the following additional lines in it:
                Message 7 of 10 , Oct 3, 2005
                • 0 Attachment
                  > -----Original Message-----
                  > From: Mark Volkmann [mailto:r.mark.volkmann@...]
                  > Sent: Friday, September 30, 2005 6:40 PM
                  > To: vim@...
                  > Subject: vimdiff usage
                  >
                  > I'm just learning how to use vimdiff to find the difference
                  > between two files. I know there are many ways to start it.
                  > I'm interested in using it after I already have vim running.
                  > Here's what I did.
                  >
                  > - open first file
                  > - ":sp" to split the window
                  > - open second file in second window
                  > - ":diffthis" in both buffers
                  > - "]c" to move to next difference
                  > - "[c" to move to previous difference
                  >
                  > That seemed to work fine. Then I wanted to turn it off, so I did this.
                  >
                  > - ":set nodiff" in both buffers
                  > - ":set noscrollbind" in both buffers
                  >
                  > Is there an easier way to set it up or turn it off?

                  You have had some good responses, I will just show you what I do.

                  In my virmce, I have the MyDiff function. I put the following additional
                  lines in it:
                  " Show a usage message as a reminder for the diff
                  " specific key mappings
                  " See Nodiff below which resets this value
                  if !exists('g:diff_msg_shown')
                  let g:diff_msg_shown = 0
                  endif

                  if g:diff_msg_shown == 0
                  echo "Diff key mappings\n".
                  \ "-----------------\n".
                  \ "]c - next diff\n".
                  \ "[c - prev diff\n".
                  \ "do - diff obtain - get change from other window\n".
                  \ "dp - diff put - put change into other window\n"
                  " This function is called once for each buffer involved
                  " in the diff, so only show the message once.
                  let g:diff_msg_shown = 1
                  endif


                  I really like diff mode, but I do not use it routinely, so I often forget
                  the commands. So this will show me the commands when I launch it. I just
                  have to press <enter> through the prompt.

                  As per the comments, my Nodiff looks like this:
                  " Courtesy of Gary Johnson
                  if v:version >= 602
                  command! -bar Nodiff wincmd l <bar> only <bar> set nodiff noscrollbind
                  scrollopt-=hor wrap foldcolumn=0 virtualedit= columns=80 <bar> let
                  g:diff_msg_shown = 0
                  else
                  command! -bar Nodiff exe 'wincmd l' <bar> only <bar> set nodiff
                  noscrollbind wrap foldcolumn=0 scrollopt-=hor virtualedit= <bar> let
                  g:diff_msg_shown = 0
                  endif



                  I launch it in 2 ways:
                  1. Either edit the first file, then type:
                  :vert diffsplit <other filename>

                  2. From the command line:
                  gvim -O -d two files

                  Since I use vert diffsplit, my MyDiff function also does this:
                  let &columns=166

                  Which essentially maximizes the display so I can see both files pretty well
                  while diffing.
                  Note the Nodiff command puts columns back to 80.

                  HTH,
                  Dave

                  --
                  Do you use Vim to edit SQL?
                  <Plug>
                  Check the description of these plugins:
                  dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
                  Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
                  SQLUtilities - Formatting SQL, generate - columns lists, procedures for
                  databases (http://www.vim.org/scripts/script.php?script_id=492)
                  sql.vim - SQL indent file for Sybase ASA and Oracle
                  (http://www.vim.org/scripts/script.php?script_id=495)
                  Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
                  (http://www.vim.org/scripts/script.php?script_id=747)
                  </Plug>
                • Peter Bismuti
                  xxdiff is the superior diff tool, thought you might want to know. ... From: Mark Volkmann To: Sent: Friday,
                  Message 8 of 10 , Oct 3, 2005
                  • 0 Attachment
                    xxdiff is the superior diff tool, thought you might want to know.
                    ----- Original Message -----
                    From: "Mark Volkmann" <r.mark.volkmann@...>
                    To: <vim@...>
                    Sent: Friday, September 30, 2005 3:39 PM
                    Subject: vimdiff usage


                    I'm just learning how to use vimdiff to find the difference between
                    two files. I know there are many ways to start it. I'm interested in
                    using it after I already have vim running. Here's what I did.

                    - open first file
                    - ":sp" to split the window
                    - open second file in second window
                    - ":diffthis" in both buffers
                    - "]c" to move to next difference
                    - "[c" to move to previous difference

                    That seemed to work fine. Then I wanted to turn it off, so I did this.

                    - ":set nodiff" in both buffers
                    - ":set noscrollbind" in both buffers

                    Is there an easier way to set it up or turn it off?

                    --
                    R. Mark Volkmann
                    Partner, Object Computing, Inc.
                  Your message has been successfully submitted and would be delivered to recipients shortly.