How to Quickly Rename Files in Vim

The purpose of this guideđź“ť is to streamline the process of renaming files frequently in Vim without using NERDTree, which can be slow. The solution involves using the Vinegar plugin along with the built-in file explorer. Additionally, we will configure Vim to return to the previous window after renaming a file by pressing Enter.

Pavol Kutaj
1 min readMar 26, 2024
Open TICKS.md → Rename to TICKETS.md
  • Open the file you want to rename in Vim.
  • Use the Vinegar plugin by pressing - to "hop up to the directory listing and seek the file you just came from"
  • → you are immediately on the opened file, the one you need to rename! No more look-ups. Wonderful!
  • Press R to start the renaming process and edit the filename as needed.
  • → you do not need to rewrite the whole filename, that is prepopulated; just make changes where you need
  • Press Enter to confirm the new filename and return to the previous window.
  • To configure Vim to return to the previous window after renaming, add let g:netrw_chgwin = 1 to your .vimrc file.
  • Or, after renaming a file, you can return to the previous window by pressing Ctrl + ^.

LINKS

--

--

Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com