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

Re: Moving diff hunks

Expand Messages
  • Ph. Marek
    Ben Schmidt yahoo.com.au writes: ... Thank you; I thought about that, but then chose the simple way. ... Yes, that could ve been the
    Message 1 of 3 , May 29, 2008
    • 0 Attachment
      Ben Schmidt <mail_ben_schmidt <at> yahoo.com.au> writes:
      > Not bad. I'd probably do it as a function: more readable, and allows you
      > to call other functions.
      > function! DiffMove()
      Thank you; I thought about that, but then chose the "simple" way.

      > That should work as long as you're careful not to anchor \%$ to the
      > beginning of the line, or it'll only work if the last line is blank.
      Yes, that could've been the problem.

      > Putting it all together:
      > function! DiffMove()
      > let winview = winsaveview()
      > k'
      > call search('^---','bc')
      > y d 2
      > ''
      > call search('^@@','bc')
      > .,.+1+/\ze\(\n@@\|\n---\|\n+++\|\%$\)/d D
      > $put d
      > call winrestview(winview)
      > endfunc
      > nnoremap dm :sil call DiffMove()<CR>
      Thank you, I'll try that!

      > ... I didn't see anything in
      > your map to change windows/buffers either, which seemed strange to me,
      > since if you move the chunk at the end of the file it will just end up
      > being put back there again. Adding appropriate commands to do that
      > shouldn't be hard, though, if you need it.
      Yes, I have them - they're CTRL-W CTRL-W to simply switch the buffers, but they
      got lost when pasting ;-)

      > You evidently know how to use the help, so I won't reference it, but
      > allow you to explore yourself if there are parts that are a little
      > obscure! If you can't find your answer in there, though, I'm sure
      > someone here will help further.


      thank you very much!



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