Vim Tips Wiki

Use this page to discuss script 1928 Rename: rename a buffer within Vim and on disk

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on
  • This page may be out of date: check the script's page above, and its release notes.


There is a conflict between this plugin and python-mode.

python-mode automatically trims unused whitespace on write[1]. For some reason, this causes this plugin to fail if we attempt to rename a Python file which does not contain any trailing whitespaces in at least one line (more thoroughly explained in this question on StackExchange [2]). --September 20, 2017

The problem is with python-mode's trim whitespace function that is called by an autocmd. As the answer in the link above suggests, the fix would be to change autoload/pymode.vim to add an e flag to the substitute command:

" DESC: Remove unused whitespaces
fun! pymode#trim_whitespaces() "{{{
    if g:pymode_trim_whitespaces
        let cursor_pos = getpos('.')
        silent! %s/\s\+$//e
        call setpos('.', cursor_pos)
endfunction "}}}

--Heptite (T) (C) (@) 16:45, September 20, 2017 (UTC)