Loading ...
Sorry, an error occurred while loading the content.

:sp - Problem

Expand Messages
  • Michael Naumann
    I do the following vim -u NONE -U NONE ... Ianything I make any change ... Vim says E37: No write since last change (use ! to override) Now I do the
    Message 1 of 2 , Nov 2, 2001
    • 0 Attachment
      I do the following

      vim -u NONE -U NONE
      :e f1 " I start editing file f1
      Ianything<ESC> " I make any change
      :sp f1 " I want to split-view this file
      " Vim says
      " E37: No write since last change (use ! to override)

      Now I do the following

      vim -u NONE -U NONE
      :e f1 " I start editing file f1
      Ianything<ESC> " I make any change
      :sp f2 " I start editing another file in another window
      :sp f1 " I again want to split-view file f1
      " Now vim says nothing and silently opens a buffer

      Where does this inconsitency come from? Is it a setting I should have?

      An related question:
      What I want is, that whenever I have a window open for a file f
      and I issue
      :sp f
      that the already present window is used.
      'switchbuf' does not apply here.

      ADVthanxANCE, Michael

      --

      Don't get sick, it's not good for your health
    • Bram Moolenaar
      ... What happens with :split f1 , while you are already editing f1 , is that Vim thinks you want to reload the file f1 . You can only have one buffer for a
      Message 2 of 2 , Nov 3, 2001
      • 0 Attachment
        Michael Naumann wrote:

        > I do the following
        >
        > vim -u NONE -U NONE
        > :e f1 " I start editing file f1
        > Ianything<ESC> " I make any change
        > :sp f1 " I want to split-view this file
        > " Vim says
        > " E37: No write since last change (use ! to override)

        What happens with ":split f1", while you are already editing 'f1", is
        that Vim thinks you want to reload the file "f1". You can only have one
        buffer for a file, and the existing one contains changes. Thus you get
        a warning.

        > Now I do the following
        >
        > vim -u NONE -U NONE
        > :e f1 " I start editing file f1
        > Ianything<ESC> " I make any change
        > :sp f2 " I start editing another file in another window
        > :sp f1 " I again want to split-view file f1
        > " Now vim says nothing and silently opens a buffer

        Now the request to edit "f1" is done while you are editing "f2", which
        is assumed to mean that you want to switch to the existing buffer for
        "f1". You didn't tell Vim to reload the file, thus you don't get a
        warning.

        Vim is doing a best-guess of what you were trying to do. Normally you
        would use ":split" if you don't want to reload the file.

        > An related question:
        > What I want is, that whenever I have a window open for a file f
        > and I issue
        > :sp f
        > that the already present window is used.
        > 'switchbuf' does not apply here.

        There is no command for this. You can write a mapping for it though.

        --
        Are leaders born or made? And if they're made, can we return them under
        warranty?
        (Scott Adams - The Dilbert principle)

        /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
        ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
        \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
      Your message has been successfully submitted and would be delivered to recipients shortly.