Thursday, March 21, 2019

Get highest Vim buffer number

I have the following line in my vimrc file. This is for vimdiff:

" dp will send middle pane changes to right pane and then immediately
" update.
nnoremap dp :diffput 3 <bar> :diffupdate<cr>

However, this only works if I'm using vimdiff with three files. If I am diff'ing two files, then calling "diffput 3" gives an error message because there is no buffer #3. How do I change the 3 to "buffer of rightmost pane"? Or separate this command into two statements? Something like the following:

If (two files are being compared) Then
nnoremap dp :diffput 2 <bar> :diffupdate<cr>

ElseIf (three files are being compared) Then
nnoremap dp :diffput 3 <bar> :diffupdate<cr>
End If

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: