vim BufEnter autocmd fails on ftp files


vim BufEnter autocmd fails on ftp files



I have an auto command triggered off BufEnter in my .vimrc to cd into the current buffer directory (very useful)

au   BufEnter *   execute ":lcd " . expand("%:p:h") 

The problem is this fails on FTP files (as you might expect). The real problem is the error message telling me it has failed. Is there any way to suppress the error message, or alternatively "cd" into the current directory for FTP files as well (to make opening other files in the directory easier).

Just making the error message go away would be very helpful though! I've tried various experiments with the :silent command, but either it's not working for this command, or I didn't put it in the correct place.




How can I prepend text in the middle of the line to multiple lines in Vim?

1:



How to set the character encoding for a file in VIM
Did you try:.
How to ignore struct declarations and consider only definitions in cscope?
au BufEnter * execute ":silent! lcd " . 


VIM: Zero-Indexed Line Numbers in :set number
expand("%:p:h")
:silent! is supposed to skip errors as well as messages..
How Does One Refresh the File List Using FuzzyFinder in Vim?
As a side note, also have a look at :h 'autochdir' which does something similar to your autocommand.


Vim plugins/features you'll die without? [duplicate]
(However see :h netrw-incompatible for caveats.).
To change TYPE to nothing from conf in Vim


How can I split horizontally across several vertically split windows in Vim?


94 out of 100 based on 84 user ratings 334 reviews