When I use vi to open a file *.c, I would like the cursor to move to the string "main" automatically. If there is no "main", I want the cursor to go to "void" without an error prompt.
In my .vimrc
I have set
:autocmd BufRead *.c 1;/main
but this cannot implement all my requirements. Specifically, if there exists no "main" in some opened C source file, vi prompts "Error, cannot find main ...." which is the behaviour I want to remove.
I have also tried adding <silent>
or :silent
to that autocmd
line, but it doesn't do what I want. Can anyone help me? Thanks.