5

I use ":set ai sw=4" and ":set number" (and some other cmd) commands each time when I open any file in VIM.

For every new instance of VIM I have to enter set of commands. Is there any way where I can put these commands and VIM will execute it every time while opening any file like default settings.

1

2 Answers 2

10

Just paste those lines on the file ~/.vimrc and they'll be executed everytime VIM is openned. If it does not exist, create one.

Two recommendations:

  1. Use a plugin that will auto-load .vimrc when you save it. Being confortable with editting .vimrc is very important. Building it up with your preferences and key-mappings as you learn VIM is one of the reasons it is so powerful.

  2. Google now for some ready .vimrc setups as they override some not-so-optimal VIM configurations. For example, you probably won't want that annoying bell beep, among many other things.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @Dokkat , created the file and working for line numbers, will explore for ready configurations.
You don't need (want?) the colons though at the beginning of each line. Also a "plugin" to autoload your .vimrc when you save it should be as easy as autocmd BufWritePost *vimrc source <afile>.
3

You need to create a .vimrc file.

You should create it in your home directory.

1 Comment

Yes, thanks a lot. created the file and got that thing in place. !

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.