| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| In vim if you edit another file with :e! file then :bnext! does the first file retain its edits in the buffer or not? I played around with this and it seems like sometimes they were kept and sometimes they were lost. How exactly does this work? CMM |
|
#2
| |||
| |||
| On 01/09/08 04:57, Charles M wrote: > In vim if you edit another file with > > :e! file > then > :bnext! > > does the first file retain its edits in the buffer or not? > I played around with this and it seems like sometimes they > were kept and sometimes they were lost. How exactly does this work? > > > CMM If the file is modified (which is usually shown by [+] on the status line) then going to a different file with an exclamation mark, or closing the window with an exclamation mark, will lose all changes since last save. If 'autowriteall' is set, then going to a different file _without_ an exclamation mark, or closing the window _without_ an exclamation mark, will save the changes first (unless the file is unnamed or read-only, in which cases there will be an error). If, instead, 'hidden' is set, the modified buffer will not be written but it will be retained in Vim memory even though it is not displayed. (However, the local 'bufhidden' option can alter for one buffer the behaviour of the global 'hidden' option.) If 'autowriteall', 'autowrite' and 'hidden' are off (which is the default), then closing the window or going to another file in the same window (but without an exclamation mark) is an error if the file is 'modified'. The commands ":w[rite]" and ":wq[uit]" will write the buffer, modified or not, if it has a name. For an unnamed buffer they give an error. An exclamation mark is required if the file is 'readonly' in Vim, or if the disk file exists and is read-only. ":up[date]", ":wqa[ll]", ":exi[t]", ":x[it]", ":xa[ll]" will write the file(s) if modified, provided that they have a name. Unnamed modified files, or, without an exclamation mark, read-only files, give an error. See also :help abandon :help E37 :help :hide and the help for the various ex-commands and options mentioned above. Best regards, Tony. -- hundred-and-one symptoms of being an internet addict: 155. You forget to eat because you're too busy surfing the net. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.