2

I am using vertical splits to compare two files which cannot be compared with diff.

I don’t know how to save specific settings in the session.

Here is how I proceed:

  1. enable the settings:
     :set nowrap
     :set scrollbind
     :set cursorbind
     :set cursorline
  1. :mks mysession.vim to create the session

  2. :wqa to exit vim

  3. nvim -S mysession.vim to reload the session

The files load correctly, but not the four settings. nvim mysession.vim does not show anything related to scrollbind, cursorbind or cursorline in the code.

How can I save these options in a session?

  • 6
    Have a look at :h 'sessionoptions' – Christian Brabandt Jul 10 at 7:38
  • 1
    Seconding Christian; this may be one of the few times where saving options in a session makes sense (in general it captures way too much). Have you tried vimdiff? – D. Ben Knoble Jul 10 at 12:19
0

Thanks for pointing to sessionoptions, this answered my question like this:

Step by step:

  1. nvim file1.txt

  2. :vsp file2.txt

  3. A perfect environment to compare files. Note: it is necessary to apply each setting individually on every buffer.

:set nowrap
:set cursorbind
:set scrollbind
:set cursorline
  1. :set sessionoptions=options

  2. :mks compare.vim

  3. :wqa!

  4. nvim -S compare.vim

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.