Renaming the current file in Vim

前端 未结 21 691
轻奢々
轻奢々 2021-01-29 17:15

How should I rename my current file in Vim?

For example:

  • I am editing person.html_erb_spec.rb
  • I would like it renamed to person
21条回答
  •  离开以前
    2021-01-29 17:45

    • Write the file while editing - :w newname - to create a copy.
    • Start editing the new copy - :e#.
    • (Optionally) remove the old copy - :!rm oldname.

    On Windows, the optional 3rd step changes a little:

    • (Optionally) remove old Windows copy - :!del oldname.

提交回复
热议问题