1

I'm trying to create my first own .vimrc file. I'm having some trouble when trying to load plugins with Vundle. For example, I want to use vim-airline, so I have (in the correct place I believe) in my .vimrc file this:

Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

I installed them using :PluginInstall succesfully. However, when I try to set the theme for the airline plugin, using in my .vimrc:

AirlineTheme luna

It doesn't work; vim says on startup E492: Not an editor command: AirlineTheme luna. When I continue and manually do :AirlineTheme luna while vim is running, it works. So for some reason, I can't use any commands provided by the plugins in the .vimrc file. What do I do wrong, or how do I circumvent this issue?

For reference, here is a stripped version of my .vimrc:

" ====== Load Plugins ======
set nocompatible              " be iMproved, required

filetype off                  " required
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Vundle manages itself
Plugin 'VundleVim/Vundle.vim'
" Add other plugins to Vundle
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

call vundle#end()
filetype plugin indent on


" ======= Allow for project specific .vimrc files =======
set exrc
set secure


" ====== Configure Plugins  ======

" Airline Theme
set laststatus=2
AirlineTheme luna

Note that it is the very last line that does not work.

  • 2
    Since this is your first vimrc, do yourself a favor and choose a different plugin manager. Just about any other would do, f.i. NeoBundle, VAM, Plug. Even Pathogen. – Sato Katsura Aug 18 '16 at 10:48
  • 1
    @SatoKatsura Any reason? I am using Vundle and it seems very easy and nice... It just does all the work for you... – Amit Gold Aug 18 '16 at 17:38
1

That command from the plugin is not available, until sourcing the vimrc is actually done. So either explicitly set the theme using let g:airline_theme = 'luna' which is the documented way to set your airline theme, or wrap your command into an VimEnter autocommand.

0

Turns out I was able to fix it using this:

let g:airline_theme = 'luna'

For now, I'll assume that the commands created by plugins are not available in your .vimrc file itself.

0

If you are editing your .vimrc file and want to load/ attempt to load it you can just run :so %

Here is a link to another answer that explains this further.

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.