Vim: :e can't create nonexistent files automatically anymore like #2274 described

Created on 4 Oct 2019  路  4Comments  路  Source: VSCodeVim/Vim

Describe the bug
Typing ":e example.txt" opens a tab with a named file which is not created or saved on the disk.

To Reproduce
Enter a file name that doesn't exist in that path.

Expected behavior
I expect the new file to be created on the disk automatically like in the previous version did, especially cause in my workflow I need to frequently create files, make use of auto save, and compile and run files.

Environment

  • Issue Type: Bug
  • Extension Name: vim
  • Extension Version: 1.11.0
  • OS Version: Windows_NT x64 10.0.18362
  • VSCode version: 1.38.1

Most helpful comment

Quoting https://github.com/VSCodeVim/Vim/commit/f70c8aa9f782881ebfe9f9de33952faa5e9a7f2c:

In the actual Vim, commands like ":e" do not create a file first if the path in the cmd doesn't exist. Rather, it creates an empty buffer and only create the file on write.
This commits changes the behavior to be more consistent with actual Vim by using untitled document instead creating the file if the file on the cmd is not found.

I'd say the behavior you describe is by design since it follows the original Vim behavior.

All 4 comments

Is this a regression to #2274 or by new design?

Quoting https://github.com/VSCodeVim/Vim/commit/f70c8aa9f782881ebfe9f9de33952faa5e9a7f2c:

In the actual Vim, commands like ":e" do not create a file first if the path in the cmd doesn't exist. Rather, it creates an empty buffer and only create the file on write.
This commits changes the behavior to be more consistent with actual Vim by using untitled document instead creating the file if the file on the cmd is not found.

I'd say the behavior you describe is by design since it follows the original Vim behavior.

@joanrieu thanks for your in-depth reply.

I understand the current behavior equals to the original Vim. But I have a few more consideration over whether to apply it to VS Code Vim Extension as well. Let me explain:

  1. I'm not sure about whether the overall goal of this extension project is to reproduce every stock behavior of the original Vim in VS Code, or, to make use of Vim philosophy together with VS Code to save people time especially on typing and moving their hand.
  2. For VS Code environment, it's weird to draw an analogy between File: New Untitled File and :e filename.ext because the first command don't accept a filename at all. When you run the better analogy which I suppose is File: New File, VS Code will actually create and save an empty file with the given name.
  3. Vim don't have features like auto-save, IntelliSense, Git, etc. out of the box, so the original behavior doesn't suit VS Code workflow very well in many aspects:

    1. Auto-save won't work until you manually save it first.
    2. IntelliSense won't work, too. At least in my C++ workspace, it won't suggest a header file placed just in the same folder.
    3. Integrated source control won't reflect that you have untracked code at all even if you have many lines entered already.

    According to these and maybe some other underlying problems like "won't work with another extension until I saved it first", I'll 99% definitely need to save it just after the creation. The 1% is I mistyped the filename. It鈥榮 bother and a waste of time to type :e filename.ext then :w for every file.


  4. VS Code Vim is not as easy to customize as original Vim using .vimrc or .vim plugins. I can't come up with a better way to do :e xxx and :w in a strike easily. (BTW, I can't use VS Code Vim to easily rename current file either.)

  5. The previous behavior is discussed and seems to work very well without complaints back to the old #2274 time. People expressed that they expect this behavior ever since then.

Anyway, if the previous behavior won't be reverted to, then this will be a major obstacle for me to upgrade the extension starting from this version. And I'd like (and have) to learn some new way to come through it like "an option", or some emulated plugins.

Similar complaint here:
for vsp:
https://github.com/VSCodeVim/Vim/issues/4098
It also affects gf for me:
https://github.com/VSCodeVim/Vim/issues/2683

Was this page helpful?
0 / 5 - 0 ratings

Related issues

triztian picture triztian  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

waltiam picture waltiam  路  3Comments

edwintorok picture edwintorok  路  3Comments

jaredly picture jaredly  路  3Comments