How To Install Vim Plugin On Vim For Windows

Vim nerdtree on Windows 10

As a beginner vim user, even just installing a plugin is already something that confusing, i don’t know why the first time i try to install vim plugin just doesn’t work, even though i believe i have followed the instruction correctly. 

So if you are someone like me, struggling to install vim plugin, you can follow this step by step guide. Actually it’s very simple, but because vim users mostly are linux users, it kind of difficult to find a reference of Vim for Windows.

Now to install a plugin, let’s start by opening our windows command prompt or there is a new cool windows terminal (if you don’t know about windows terminal, this is a really cool terminal, you can read in my previous article here).

Move to HOME/vimfiles/pack/vendor/start directory using cd command. If the path doesn’t exist, you can manually create it. Note that the HOME is your home directory, on windows, Home directory usually something like C:/Users/your_username.

Now clone the source code of the vim plugin that we want to install, in this example, i am going to install nerdtree:

cd vimfiles/pack/vendor/start
git clone --depth 1 https://github.com/preservim/nerdtree.git

Those are downloading nerdtree source code, without commit history, so it’s smaller in size.

Actually that’s the only required process of how you install a vim plugin on Windows, there's no extra things, except if you want to do configuration, but we're not going to do that right now. 

We only need to test if our nerdtree plugin is being installed or not, simply by opening your vim, type:

vim
:NERDTree C:/your_project

NERDTree is a vim plugin to add file explorer interface to our vim. With it you can navigate between files in your vim terminal like a file explorer, you can use the arrow key like up and down yo navigate each file you want to operate. And you can use enter to open the enter a folder or to open the file.

Here’s some useful keys when you are using nerdtree:

  • To open file in a tab mode, use capital T key instead of just enter
  • CTRL + w w, to hop between tree navigation and the editor
  • gt or gT, to switch between tab
  • To quit editor, like usual :q

Also some useful vimrc configuration:

" some vim customs configuration
set tabstop=4
set shiftwidth=4
set whichwrap+=<,>,[,]
vmap <Tab> >gv
vmap <S-Tab> <gv
let NERDTreeShowHidden=1
set undofile
set undodir=C:/Users/your_username/vimfiles/cache/
set dir=C:/Users/your_username/vimfiles/cache/
set backupdir=C:/Users/your_username/vimfiles/cache/
set spell spelllang=en_us
set spellfile=C:/Users/your_username/vimfiles/cache/en.utf-8.add

I have known vim for a while but this time i actually really want to explore more about using vim, sometimes i use vim only for when i am connecting to a remote server via SSH, as the server usually doesn't have a user interface.

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Spring Kafka - How to use ReplyingKafkaTemplate send and reply synchronously