Saturday, October 25, 2014

Re: Starting vim with number and wrap set in diff mode

On 24 October 2014, Steve Graham <solitary.wanderer52@gmail.com> wrote:
> I am starting vim in diff mode (vim -d) and find that I also need
> number and wrap set. I can start vim with it (as in vim -c 'set
> number' -c 'set wrap' -d file1 file2), but number and wrap are only
> set for the left window and not the right one.
>
> How can I have it set for both?

It can be done, but you probably won't like the solution. There are
only two command line options that seem relevant here:

* -c <command>, which runs <command> after loading the first file
* --cmd <command>, which runs <command> before loading any vimrc file

The first version has no effect on the second file. The second is
run too early:

vim --cmd 'set nu wrap' -d file1 file2

will set numbers, but wrap will get overridden by -d. And there is no
command that gets run after loading each file, or after loading all
files.

Thus the trick is to start diff mode after loading the files, like
this:

vim -c 'diffsplit file2 | set nu wrap | winc l | set nu wrap' file1

Or if you prefer to have the file names at the end:

vim -c 'exec "diffsplit " . argv(1) | set nu wrap | winc l | set nu wrap' file1 file2

/lcd

--
--
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:

Post a Comment