Renaming the current file in Vim

前端 未结 21 884
轻奢々
轻奢々 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 18:00

    :!mv % %:h/new_name
    

    Register % contains the name of the current file.'%:h'shows the directory 'head' containing the current file, e.g.: %:hreturns /abc/def when your file full path is abc/def/my.txt

提交回复
热议问题