From 5e55d8981da5cd2e609ab0346098dc467571c54e Mon Sep 17 00:00:00 2001 From: brucedsu Date: Wed, 16 Jul 2014 22:56:50 +0800 Subject: [PATCH] Auto-escape spaces in file names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I love your RenameFile() function. However there are two problems. The first one is that some files have spaces in their names. The solution is to use escape() function to escape those spaces. The second on is that I created an alias for my rm command. I am using “rm -i” for rm, so I can not delete the origin file when I am using MacVim (I don’t know why it doesn’t prompt me to enter “y”). The solution is to add “-rf”. --- vimrc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vimrc b/vimrc index 230a6b347c..ce3b7357f1 100644 --- a/vimrc +++ b/vimrc @@ -106,7 +106,7 @@ map h :CommandT map i mmgg=G`m map j :CommandT app/assets/javascriptsclient/ map l oconsole.log 'debugging':w -map m :Rmodel +map m :Rmodel map nn :sp ~/Dropbox/notes/programming_notes.txt map o :w:call RunCurrentLineInTest() map p :set pasteo"*]p:set nopaste @@ -118,23 +118,23 @@ map rs :vsp #w map rt q:?!ruby map rw :%s/\s\+$//:w map sc :sp db/schema.rb -map sg :sp:grep +map sg :sp:grep map sj :call OpenJasmineSpecInBrowser() -map sm :RSmodel +map sm :RSmodel map sp yss

map sn :e ~/.vim/snippets/ruby.snippets map so :so % map sq j}klllcs:wq map ss ds)i :w map st :!ruby -Itest % -n "//" -map su :RSunittest -map sv :RSview +map su :RSunittest +map sv :RSview map t :w:call RunCurrentTest() map y :!rspec --drb % map u :Runittest map vc :RVcontroller map vf :RVfunctional -map vg :vsp:grep +map vg :vsp:grep map vi :tabe ~/.vimrc map vu :RVunittest map vm :RVmodel @@ -209,14 +209,14 @@ let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**; highlight StatusLine ctermfg=blue ctermbg=yellow " Format xml files -au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null" +au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null" set shiftround " When at 3 spaces and I hit >>, go to 4, not 5. set nofoldenable " Say no to code folding... command! Q q " Bind :Q to :q -command! Qall qall +command! Qall qall " Disable Ex mode @@ -381,11 +381,11 @@ highlight SignColumn ctermbg=black " RENAME CURRENT FILE (thanks Gary Bernhardt) """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" function! RenameFile() - let old_name = expand('%') - let new_name = input('New file name: ', expand('%'), 'file') + let old_name = escape(expand('%'), ' ') + let new_name = escape(input('New file name: ', '', 'file'), ' ') if new_name != '' && new_name != old_name exec ':saveas ' . new_name - exec ':silent !rm ' . old_name + exec ':silent !rm -rf ' . old_name redraw! endif endfunction