I got two files named as vim1 and vim2. vim1 files has some text in it, but vim2 is totaly empty. I used vim vim1 command to open that file. Later on i write :vsplit vim2 to open vim2 file on splited side. I changed my beam to vim2 screen with Ctrl+w command. Later i write this :e vim1 at vim2's split. And i write :wq at this split. After i close the both splits, i checked vim2 file and it was totaly empty. How did this happen?
Let us look through your sequence of events, with slightly more clear filenames:
- (presumably, make edits to
file2as a vertical split with
:vsp file2This puts the cursor into
file2's new split.
- Move cursor with Ctrl-W to
- Move the cursor with unspecified means back to
- Execute the command
:e file1, which changes the active buffer in what was
file2's split to also be used to display and edit
:wqto save and quit
file1, in the split which had originally been used for
At no time was
file2 written to in this chain of events, which is why the file is empty (if it even exists).
Note that at the end of this chain of events, the state of
vim will be
file2, as the only remaining open buffer (in what had been the split which was used for
file1, which was just closed), open in an unsplit interface, as yet unsaved.