On Tuesday, September 16, 2014 6:04:41 AM UTC-5, Marslo Jiao wrote:
> Because of some reason, the .vimrc file and .vim folder has been saved in the specified location:
> - .vimrc: ~/.marslo/.vimrc
> - .vim: ~/.marslo/.vim/
> - colorscheme is marslo256.vim (made by myself): ~/.marslo/.vim/bundle/marslo.vim/colors/marslo256.vim
>
This is a non-standard setup. I assume you have a plugin manager (Pathogen?) to
let you use the 'bundle' directory, and I further assume you set it up as
directed by the plugin installation instructions; but why is your entire setup
in an extra directory under $HOME? How did you get that into your runtimepath?
(Nevermind, I finally noticed your .vimrc link at the bottom, the extra
directory seems to come from your "portable" settings which look pretty clever).
> I found that, the Error as blow will show EVERYTIME while .vimrc saving:
> ```
> Error detected while processing /root/.marslo/myprograms/vim74/share/vim/vim74/syntax/synload.vim:
> line 19:
> E185: Cannot find color scheme 'marslo256'
> Press ENTER or type command to continue
> ```
>
> In My .vimrc file, there's a command would be executed in every .vimrc saving for autoloading the change of vimrc:
> ```
> autocmd! bufwritepost $HOME/.marslo/.vimrc source %
> ```
To me this indicates maybe your runtimepath is not set up correctly. I'm not
sure what Pathogen or other plugin managers do when you tell them to use a
specific bundle directory and they are already using that directory. I don't
know where in your .vimrc you set the colorscheme, whether your plugin
manager is fully initialized beforehand or not, or whether syntax or filetype
detection is already enabled before the command runs the first time.
>
> And I also checked the Line 19 in syntax/synload.vim:
> ```
> 17 " Set the default highlighting colors. Use a color scheme if specified.
> 18 if exists("colors_name")
> 19 ¦ exe "colors " . colors_name
> 20 else
> 21 ¦ runtime! syntax/syncolor.vim
> 22 endif
> ```
Perhaps when this script runs, the runtimepath has not been fully set up yet?
The first time it runs (on launching Vim) g:colors_name would not be set yet
because you have not yet set a colorscheme. But subsequent launches would see
the previous value. Your autocmd could unlet that variable prior to sourcing the
.vimrc if this is the root cause.
>
> Then, I tried analyzed the `startuptime` for launching `.vimrc` file, the
> "startuptime" file can be found at:
>
https://github.com/Marslo/test/blob/master/vimrc_startuptime. Something wired,
> because "/root/.marslo/myprograms/vim74/share/vim/vim74/syntax/syncolor.vim"
> file has been launched FOUR TIMES (l18, l38, l39, l40) !!! WHY ???
>
> Never mind, because of there NOTHING wrong while start .vimrc at first time.
>
Where does startuptime come into this discussion? Or are you asking a new
question now? Your problem was just when sourcing .vimrc after launching Vim
already correct?
It is interesting that the script gets sourced multiple times. This is likely
due to changing colorschemes or applying a syntax or something. I'm not sure of
the exact reasons this script would be sourced, but I know it is not abnormal to
source a few of the runtime scripts on multiple occasions.
Oops, I didn't notice you posted your .vimrc!
It looks like one of my assumptions were correct, you're using both Pathogen
*and* Vundle. Ok, I guess that would *probably* work fine.
But it also looks like they're not installed per the instructions. You start by
turning on filetype and indent detection, and syntax highlighting, and then you
turn it off again. THEN you set up both your plugin managers. I think you're
supposed to set up your plugin managers prior to turning on filetype detection
or syntax.
I suspect the filetype commands and the syntax command may be sourcing
syncolor.vim. If that is the case, since these commands come before your
runtimepath is set up, your colorscheme won't be found.
First, I would try re-arranging your .vimrc so the Vundle/Pathogen setup comes
earlier; almost at the top. Probably right after you initialize your
runtimepath.
If that doesn't solve the problem, then as a workaround, try my other
suggestion, using :unlet g:colors_name in your autocmd prior to sourcing your
.vimrc.