Skip to content

Instantly share code, notes, and snippets.

@romainl
Last active December 24, 2024 10:29
Show Gist options
  • Select an option

  • Save romainl/7198a63faffdadd741e4ae81ae6dd9e6 to your computer and use it in GitHub Desktop.

Select an option

Save romainl/7198a63faffdadd741e4ae81ae6dd9e6 to your computer and use it in GitHub Desktop.

Revisions

  1. romainl revised this gist Apr 24, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions diff.md
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,11 @@ Where the original `:DiffOrig` only shows differences between the buffer in memo

    * against the file on disk, like the original, with:

    :Diff
    :Diff

    * against an arbitrary Git revision of the current file, with:

    :Diff HEAD
    :Diff HEAD

    ---

  2. romainl revised this gist Apr 24, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions diff.md
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,11 @@ Where the original `:DiffOrig` only shows differences between the buffer in memo

    * against the file on disk, like the original, with:

    :Diff
    :Diff

    * against an arbitrary Git revision of the current file, with:

    :Diff HEAD
    :Diff HEAD

    ---

  3. romainl revised this gist Apr 13, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion diff.vim
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ function! Diff(spec)
    setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile
    let cmd = "++edit #"
    if len(a:spec)
    let cmd = "!git -C " . shellescape(fnamemodify(finddir('.git', '.;'), ':p:h')) . " show " . a:spec . ":#"
    let cmd = "!git -C " . shellescape(fnamemodify(finddir('.git', '.;'), ':p:h:h')) . " show " . a:spec . ":#"
    endif
    execute "read " . cmd
    silent 0d_
  4. romainl revised this gist Apr 13, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions diff.vim
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    function! Diff(spec)
    vertical new
    setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile
    let cmd = "++edit"
    let cmd = "++edit #"
    if len(a:spec)
    let cmd = "!git show " . a:spec . ":"
    let cmd = "!git -C " . shellescape(fnamemodify(finddir('.git', '.;'), ':p:h')) . " show " . a:spec . ":#"
    endif
    execute "read " . cmd . "#"
    execute "read " . cmd
    silent 0d_
    diffthis
    wincmd p
  5. romainl revised this gist Apr 12, 2020. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions diff.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,17 @@
    # :DiffOrig but smarter

    This `:Diff` command is an enhanced version of the snippet provided under `:help diff-original-file`.
    This is an enhanced version of the snippet provided under `:help diff-original-file`.

    Where the original `:DiffOrig` only shows differences between the buffer in memory and the file on disk, this command can be used in two ways:
    Where the original `:DiffOrig` only shows differences between the buffer in memory and the file on disk, `:Diff` can be used in two ways:

    * against the file on disk, like the original, with:

    :Diff

    * against an arbitrary Git revision of the current file, with:

    :Diff HEAD
    :Diff HEAD

    ---

    [My Vim-related gists](https://gist.github.com/romainl/4b9f139d2a8694612b924322de1025ce).
  6. romainl revised this gist Apr 12, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions diff.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # :DiffOrig but smarter

    This `:Diff` command is an enhanced version of the snippet provided under `:help diff-original-file`.

    Where the original `:DiffOrig` only shows differences between the buffer in memory and the file on disk, this command can be used in two ways:
  7. romainl created this gist Apr 12, 2020.
    11 changes: 11 additions & 0 deletions diff.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    This `:Diff` command is an enhanced version of the snippet provided under `:help diff-original-file`.

    Where the original `:DiffOrig` only shows differences between the buffer in memory and the file on disk, this command can be used in two ways:

    * against the file on disk, like the original, with:

    :Diff

    * against an arbitrary Git revision of the current file, with:

    :Diff HEAD
    14 changes: 14 additions & 0 deletions diff.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    function! Diff(spec)
    vertical new
    setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile
    let cmd = "++edit"
    if len(a:spec)
    let cmd = "!git show " . a:spec . ":"
    endif
    execute "read " . cmd . "#"
    silent 0d_
    diffthis
    wincmd p
    diffthis
    endfunction
    command! -nargs=? Diff call Diff(<q-args>)