8

I'd like to echo a custom message upon startup, based on whether or not certain startup functions were successful. I tried this in my .vimrc

echo 'test'

"All my settings
...

I'd like vim to echo a message as if I had just typed

echo 'foo'

from the command line after opening vim, but instead I get this obnoxious dialog box that comes up before my vim windows has even opened. I also tried

exe 'echo "test"'

and

silent echo 'test'

but neither of these worked.

  • 6
    you might need to postpone the echo until VimEnter has fired – Christian Brabandt Jul 20 '16 at 17:22
12

You might want to use an autocommand that runs after VimEnter is triggered.

The autocommand can look something like this:

autocmd VimEnter * echo 'foo'

When vim starts up, it runs the command, and 'foo' is visible in the bottom left, as it would if you had just run the command.

You would put this autocommand somewhere in your .vimrc

  • how do we can use this logic (autocmd VimEnter * echo 'foo') for vi editor. we can still view the file without echo message in "vi". – Deepak Feb 9 '17 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.