0

So I have the following file number11.py open in vim, this is the route I usually take to create a new file I do ESC :save number11.py, and then :x. Then from my Ubuntu terminal I do the following vim number12.py. Is there a straight forward command I do from the beginning ESC to create the newfile number12.py?

3
  • You can use the command :saveas {newfilename}. See :help :saveas
    – Wolf
    Jul 6 '20 at 16:53
  • @Wolf Yeah that is what I was thinking because I have used that command before, however, I was researching and found that on StackOverflow they suggested using %. Jul 6 '20 at 16:54
  • % means the current file (and nice-to-know, %:h means the directory of the current file).
    – Wolf
    Jul 6 '20 at 16:56
2

What I would do is the following:

ESC :w to write (save) the file. Then :e number12.py. That will open a new buffer in the current window, if the file doesn't exist.

1
  • Exactly what I was looking for thanks. Jul 6 '20 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.