OOZOU
お問い合わせ
Back to TIL
vim

Rename files in VIM

2020年10月13日

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

vim2020年10月13日

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

vim2020年10月13日

How to really!! quit vim

In terminal

vim2020年10月13日

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

サービス

  • ウェブ開発
  • AI・生成AIソリューション
  • モバイルアプリ開発
  • データ分析・エンジニアリング
  • UI/UXデザイン・プロダクトデザイン
  • デジタルトランスフォーメーション

会社情報

  • 会社概要
  • 採用情報
  • ブログ
  • ホワイトペーパー
  • 事例研究
  • Today I Learned
  • お問い合わせ

その他

  • 業界
  • 見積もりを取得
  • パートナーネットワーク
© 2026 OOZOU. All rights reserved.
プライバシーポリシー行動規範ABACポリシー