You can even "install" local plugins outside of your ~/.vim directory.įinally, start Vim and prompt vim-plug to install the plugins listed in ~/.vimrc: :PlugInstall (The NERDTree file manager is used above as an example.) If the plugin you want isn't hosted on GitHub, then you can provide the full URL instead of just the GitHub username and project ID. Install vim-plug so that it auto-loads at launch with: $ curl -fLo ~/.vim/autoload/plug.vim -create-dirs \Ĭreate a ~/.vimrc file (if you don't have one already), and enter this text: call plug#begin()Įach time you want to install a plugin, you must enter the name and location of the plugin between the plug#begin() and plug#end lines. There are several package managers to choose from, and they're each different, but vim-plug has some great features and the best documentation of them all, which makes it easy to start with and to explore in depth later. Since Vim series 8, package managers have become less useful, but some users still prefer them because of their ability to auto-update several plugins. Using a Vim package manager (any Vim version) ![]() For example, if you were to install the NERDTree plugin and the imaginary foo plugin, you would create this structure: $ mkdir -p ~/.vim/pack/NERDTree/start/ Officially, Vim recommends that each plugin project gets its own directory within ~/.vim/pack. If you don't want a plugin to load automatically every time you launch Vim, you can create an opt directory within your ~/.vim/pack/vendor directory: $ mkdir ~/.vim/pack/vendor/optĪny plugins installed into opt are available to Vim, but they're not loaded into memory until you add them to a session with the packadd command.įor example, to load an imaginary plugin called foo: :packadd foo Launch Vim or gvim, and type this command: :NERDTreeĪ file tree will open along the left side of your Vim window. First, use Git to clone a snapshot of the NERDTree repository: $ git clone -depth 1 \ Now you can place Vim plugins in ~/.vim/pack/vendor/start, and they'll automatically load when you launch Vim.įor example, try installing NERDTree, a text-based file manager for Vim. vimrc file, and then it scans all directories in ~/.vim for plugins contained in pack/*/start.īy default, your ~/.vim directory (if you even have one) has no such file structure, so set that up with: $ mkdir -p ~/.vim/pack/vendor/start When you start Vim, it first processes your. ![]() (The examples below use the generic name vendor to indicate that the plugins are obtained from an entity that is not you.) By default, your Vim settings are contained in ~/.vim, so that's where Vim looks for plugins when you launch it. Install plugins manually (Vim 8 and above)Ī Vim package is a directory containing one or more plugins. You can use a package manager regardless of what version you run (including releases older than 8.x), which makes the install process easier than maintaining updates yourself.īoth the manual and automated methods are worth knowing, so keep reading to learn about both. You may encounter old instructions online or in project README files, but as long as you're running Vim 8 or greater, you should install according to Vim's official plugin install method or with a Vim package manager. As of the Vim 8.x series, however, there's a structure around how plugins are intended to be installed and loaded. Vim is extensible through plugins, but for a long time, there was no official method for installing them. ![]() You can customize your theme, and you can add syntax highlighting, code linting, version trackers, and much much more. With the right mix of plugins, you can take control of your life and forge your own unique Vim experience. At least, that's what it would be without plugins, which build upon Vim and add extra features to make it so much more than just a window for typing text. While Vim is fast and efficient, by default, it is but a mere text editor.
0 Comments
Leave a Reply. |