" Yank filename to to '0, with spaces quoted " (Note: '" doesn't follow '0, so use the former so that they both get updated.) nmap % :let @" = substitute(@%, ' ', '\\ ', 'g') " Yank file name into '0 " (@" represents the unnamed register and '0) nmap y :let @" = bufname()