OOZOU
與我們聯繫
Back to TIL
vim

Rename files in VIM

October 13, 2020

Here's a handy function that I use to rename files in VIM (works in MacVIM and Neovim too)

function! RenameFile()
    let old_name = expand('%')
    let new_name = input('New file name: ', expand('%'), 'file')
    if new_name != '' && new_name != old_name
        exec ':saveas ' . new_name
        exec ':silent !rm ' . old_name
        redraw!
    endif
endfunction
nnoremap <leader>n :call RenameFile()<cr>

NOTE: I've used <leader> which is mapped to comma in my config. but you can use whatever key combiniation you like.

More on vim

vimOctober 13, 2020

How to quit Vim

1. Install latest version of Vim 2. Open a file in Vim 3. ⌘-Q and close the terminal 4. Reopen terminal

vimOctober 13, 2020

How to really!! quit vim

In terminal

vimOctober 13, 2020

How to save a file with sudo in VIM

How to save a file with sudo in VIM

有專案構想嗎?

我們很樂意聆聽您正在打造的產品。

開始對話hello@oozou.com
OOZOU Logo

曼谷 · 新加坡 · 香港

X
Facebook
Instagram
LinkedIn

服務

  • Web 開發
  • AI 與生成式 AI 解決方案
  • 行動應用程式開發
  • 資料分析與工程
  • UI/UX 設計與產品設計
  • 數位轉型

公司

  • 關於我們
  • 職涯
  • 部落格
  • 白皮書
  • 案例研究
  • Today I Learned
  • 聯繫我們

更多

  • 產業
  • 索取報價
  • 合作夥伴網絡
© 2026 OOZOU. 版權所有。
隱私政策行為準則反賄賂反貪腐政策