When I use Vim and type in the
:w command, sometimes I will tap
\ by accident before I tap the Enter key because these keys are close to each other. As a result, I will get files such as
']' in my directory.
So I want to execute some autocmd in Vim to check if the file name which is going to be saved contains such special characters.
I have searched through the Internet, almost all of them give the solution of something like
expand("%:p") to get file name. But after testing it by myself, this function can only obtain the current file name instead of the one I passed to
Is there any idea of obtaining the file name passed to
:w command in Vim's autocmd?