The Vim Config file

Mike Hartington
InstructorMike Hartington

Share this video with your friends

Send Tweet
Published 5 years ago
Updated a year ago

Now that you know how to enable features in Vim, let's store all of them in one place so we don't need to constantly set them all the time.

[00:01] In our last lesson, we looked at how we can set of Vim's options once we have the editor running. While this works, it's not ideal. If we were to quit the editor and, then, start it back up again, we'd have to go back and reset all those options all over.

[00:19] Instead, we can create a Vim config file called .vimrc and store all of our options there. This file sits in our home directory and will be run every time we start Vim. Let's quit this file and, then, start a new Vim session.

[00:36] This time, we're going to create our Vimrc file. To start off our RCFile, we'll add the original options for syntax highlighting and line numbers. Let's also enable some file type detection and some features to expand tabs into two spaces.

[01:01] Lastly, we'll enable being able to backspace over essentially anything. With these settings in place, we'll save and quit Vim, then open our sample.js file again. Now we have all these settings in place, and we didn't need to enable them one by one.

[01:23] The Vimrc file can be as minimal as the one we've just created or much more complex, loading other scripts that add more functionality to the editor.

Boris LOUBOFF
Boris LOUBOFF
~ 5 years ago

Hi, thanks for this short videos. Would it be possible to share the .vimrc file used to get the result shown at the very end of the last video ? Thank you.

David Gomez
David Gomez
~ 5 years ago
ephemera
ephemera
~ 5 years ago

thanks for sharing your .vimrc file! I also found :vsp, :sp, :!, :colorscheme very useful too.

Nick Ostrovsky
Nick Ostrovsky
~ 5 years ago

Hi, how do you autocomplete in shell?

Mike Hartington
Mike Hartingtoninstructor
~ 5 years ago

Thats built in. If you start typing the name of anything, you can type the first few letters then hit <tab> to complete it

Xavier
Xavier
~ 5 years ago

Great stuff @mike!

C. Corey Capel
C. Corey Capel
~ 5 years ago

The Tab key will attempt to autocomplete in the shell. Tab will also attempt to autocomplete the text you type when in vim's command mode.

Dan
Dan
~ 5 years ago

Thanks for the series. Can you do some for plugins?

hima
hima
~ 5 years ago

..i went to ur dotfiles github page and ran these statements on my terminal..(Since i already have git, node, npm installed on my mac)

brew tap thoughtbot/formulae brew install rcm git clone https://github.com/mhartington/dotfiles.git ~/.dotfiles cd $HOME rcup

now my vim is not working..it complaining this... [dein] Does not work this version of Vim (703). [dein] Does not work this version of Vim (703). Error detected while processing /Users/siva/.vimrc: line 26: E117: Unknown function: dein#begin

skorp
skorp
~ 5 years ago

update your vim or install it via brew: brew install vim --with-lua add an alias to the new installed vim folder .bashrc or aliases file if you have one.

alias vim="/usr/local/Cellar/vim/7.4.873/bin/vim"