Tags: automatically, hints, line, linux, numbering, software, turn, unix, vim, vimdiff, vimrc

VIM: how to turn off line numbering when using vimdiff?

On Software » Linux & Unix

3,357 words with 4 Comments; publish: Thu, 22 May 2008 20:02:00 GMT; (40093.75, « »)

Hello,

in my .vimrc I have "set nu" to turn on line numbering.

Now, I want to turn it off automatically when using vimdiff.

Please, give me some hints how to do it.

Best Regards,

Przemek

All Comments

Leave a comment...

  • 4 Comments
    • In article <1122534291.105540.280070.linux-unix.itags.org.o13g2000cwo.googlegroups.com>,

      "voice" <p.hausman.linux-unix.itags.org.gmail.com> wrote:

      > Hello,

      > in my .vimrc I have "set nu" to turn on line numbering.

      > Now, I want to turn it off automatically when using vimdiff.

      > Please, give me some hints how to do it.

      > Best Regards,

      > Przemek

      if &diff

      set nonu

      endif

      Bob Harris

      #2; Thu, 22 May 2008 20:05:00 GMT
    • Mikolaj Machowski wrote:

      > From diff.txt:

      > In your .vimrc file you could do something special when Vim was started in

      > diff mode. You could use a construct like this: >

      > if &diff

      > setup for diff mode

      > else

      > setup for non-diff mode

      > endif

      I tried this construction before I wrote to the group...

      But it works only if vim is *started* in diff mode.

      When I edit a file (in normal mode) and then I want to execute "Split

      with diff..." (:browse vert diffsplit) this construction does not work.

      I suspect that some "au" commands should be used here but I have no

      idea which event should trigger an action.

      Some more hints, please?

      BTW, I use gVim for Windows, version 6.3.

      Best Regards,

      Przemek

      #3; Thu, 22 May 2008 20:06:00 GMT
    • voice <p.hausman.linux-unix.itags.org.gmail.com> wrote:

      > Mikolaj Machowski wrote:

      >

      > I tried this construction before I wrote to the group...

      > But it works only if vim is *started* in diff mode.

      > When I edit a file (in normal mode) and then I want to execute "Split

      > with diff..." (:browse vert diffsplit) this construction does not work.

      > I suspect that some "au" commands should be used here but I have no

      > idea which event should trigger an action.

      I use the FilterWritePre autocommand event (see ":help

      FilterWritePre") to set Set virtualedit=all whenever diff mode is

      entered, whether by starting vim as vimdiff or by executing

      :diffsplit in an already-running vim. For setting nonu, the command

      in your .vimrc would look like this:

      au FilterWritePre * if &diff | set nonu | endif

      HTH,

      Gary

      #4; Thu, 22 May 2008 20:07:00 GMT