Closed lourenci closed 4 years ago
you definitely can open a new tab with the buffer you want to see diffs for and run :Gvdiffsplit. Also it must work, if you press dv and close the status window with either :q or gq, the diff window will remain, I did it just yesterday
This is not practical.
Most of the time, I want to diff more than one file, so closing :Gstatus
will make me have to open it again. It's so simple with another tab, I could simply close the tab to be in :Gstatus
again.
:Git difftool -y <file>
opens a diff in a new tab. There's no map for it, but you could implement your own on top of the .
map.
Can I open a PR for that, @tpope? Thanks for the library.
I want to retool maps such that the big leader keys like d
and c
bring up an interactive popup window, and until that happens, I'm not really interested in continuing to pile onto the existing mess. I recommend implementing such a map locally using autcocmd User FugitiveIndex
.
Sorry for necrobumping, but I want to have create a mapping just like you suggested, @tpope, and fail to do so.
I want the mapping to open a diff against HEAD in a new tab for the file under cursor. There are two problems:
:Gdiffsplit
but compare against HEAD (not the current file against another)My draft:
augroup custom_fugitive_mappings
au!
au User FugitiveIndex nnoremap <buffer> dt :tab Gdiffsplit @ <filename>
augroup END
How can I do this with fugitive? Is there a fugitive-way to get <filename>
? In the :help fugitive-revision
I didn't find anything. I'd prefer to call some fugitive function for this, instead of hacking something with getline('.')
.
Any help would be appreciated.
Nevermind, I found this and tweaked it a little.
So for everyone else with this problem, I've got a working solution:
function! GStatusGetFilenameUnderCursor()
return matchstr(getline('.'), '^[A-Z?] \zs.*')
endfunction
command! GdiffsplitTab call GdiffsplitTab(expand("%"))
function! GdiffsplitTab(filename)
exe 'tabedit ' . a:filename
Gdiffsplit
endfunction
" custom mapping in fugitive window (:Git)
augroup custom_fugitive_mappings
au!
au User FugitiveIndex nnoremap <buffer> dt :call GdiffsplitTab(GStatusGetFilenameUnderCursor())<cr>
augroup END
Fugitive index buffers remap <C-R><C-F>
to do this, and there's an equivalent <Plug>
map of <Plug><cfile>
.
@tpope @sflip
So what's the best way to open diffs in tab from :Git?
I didn't quite understand about
Plugging into the original proposition it would look something like
au User FugitiveIndex nmap <buffer> dt :Gtabedit <Plug><cfile><Bar>Gdiffsplit<CR>
@tpope Perfect, thanks a lot. Why not to add it into plugin? I think it's super useful.
Would love to see this put into fugitive, I think it makes a lot of sense.
Plugging into the original proposition it would look something like
au User FugitiveIndex nmap <buffer> dt :Gtabedit <Plug><cfile><Bar>Gdiffsplit<CR>
What is the benefit of using an Autocommand on FugitiveIndex
over creating the mapping via ftplugin/fugitive.{vim,lua}
?
First off, thanks for the plugin.
I'd like to perform a diff on the file under the cursor in
:Gstatus
without waste part of my screen with the:Gstatus
window. Is there some way to perform this diff in a new tab? I just found these maps in the docs: