English

How To Create Vim Dotfile

Do you want to create a Vim dotfile? Well, we got you covered. In today’s article, we will discuss how to create Vim dotfile.

If you are not new to programming, you already know the importance of dotfiles.

Dotfile is a hidden file in a system aimed at more advanced users such as developers, programmers or engineers who love to tweak with the system.

So, basically, what they are for?

Dotfiles are powerful entities in a system that holds configuration in their own way. Technically, they store values used by a program or a system.

They start with a dot(.), for example, .xyz, and are hidden from the reach of normal users.

With the concept of dotfiles cleared, we can now focus on Vim and the role of dotfiles in Vim text editor.

How To Create Vim Dotfile

If you are not new to Linux/Unix systems, you already know that Vim stands for the most powerful text editor. The configurability depends on dotfiles.

Not only Vim, but other components of the Unix/Linux system also utilize dotfiles for storing configuration and other vital details for the proper functioning of the system. For example, the configuration files for Unix based systems start with dot(.) like .gitgnore or .bash_profile.

The Unlimited Ways You Can Use Vim

Vim is highly customizable. It can work the way you want it too. To do so, you need to make the use of dotfiles. Dotfiles are easy to edit and work with. All you need to do it learn Vimscript and customize it according to your preferences.

Before we dive into the Vim dotfile, let’s explore some of the reasons why people choose Vim over any other text editor.

Reasons to choose Vim

Vim is a rich text editor. There are tons of benefits associated with Vim. Let’s list them below.

  • Vim is a fully customizable IDE. The capability to tap into CLI tools can easily improve working experience.
  • Just like any other framework, text editors also requires community. Vim is one of the oldest text editor and hence has a plethora of solutions for common problems to Vim. If you get stuck by any problem, you can quickly use Google search to find the solution.
  • Vim universal presence is a plus on its own. Linux/Unix machines already have Vim integrated, making it easy for anyone to get started with it.
  • Compared to current generation text editors, Vim is lightweight and faster.
  • Vim is continuously developed. New features are integrated into regular instances. For example, multiple cursors in Sublime gets implemented instantly in Vim after its release.
  • Vim learning curve can be daunting, but with time, it becomes easier and you will benefit from Vim as a programmer.
  • There is no limitation of Vim in regard to language usage. It can be used with any programming language.

More About Vim’s Dotfile

Vim(Short form of “Vi Improved”) stores text editor’s configuration in a dotfile. The dotfile is named as “.vimrc” on Linux/Unix based systems. If you are using a Windows system, it is named as “_vimrc”.

To make proper use of the dotfile, you need to edit it according to your preference. In the below section, we will see how to edit a Vim dotfile.

Create Vim dotfile

First thing, that you need to check if .vimrc file is present. To make sure that the file is available, run the following command.

cat ~/.vimrc

For many reasons, the “vimrc” file may not already be present. To manually create the .vimrc file, run the following code in your Linux/Unix terminal.

touch ~/.vimrc

With the file created, we can now move forward to some examples of how to utilize the .vimrc file.

Editing Vim Dotfiles and Examples

The vim dotfile can be edited in any of your favorite text editors. You can use Gedit, Nano or even Vim for editing purposes. After opening the file, you need to utilize VimScript to configure it.

Vim utilizes Vimscript. Yes, you need to learn Vimscript if you want to add configuration to your working environment and want to create a dotfile in the process. But, don’t worry, Vimscript is easy to learn and can be mastered in a few hours.

So, how it’s done?

Let’s see some examples of Vim dotfile configurations.

  1. Setting up the auto-indent and text width

One of the simplest configuration that you can do it set auto-indent and also provide text-width to your Vim editor. To do so, you just need to put the following code in your dotfile.

set autoindent
set textwidth=80

The auto-indent automatically set the indentation required for some programming languages to work. For example, Python. The textwidth fixes the number of characters per line, in this case, 80.

  1. Getting tabs ready

Tabbing is one of the most important aspects of code readability. And, if you are using Python, you already know how important tabbing can be. Without proper tabbing, your Python code will be unreadable and may not function properly.

To ensure that indentation is set correct, use the following code in your Vim’s dotfile.

set expandtab
set tabstop = 4
set softtabstop = 4
set shiftwidth = 4

The above two examples are more than enough to show you the power of dotfile configuration.

You can also store your dotfiles on GitHub for easy access. Not only it saves time, but it also removes the chances of error propagation during project configuration stages.

Learning Vimscript and Vim

You can review a great resource on the internet to learn Vimscript. It is named as learn Vimscript the hard way.

On the other hand, you can check our superstar broadcasters, Alex Brooker who shared a two-part video series with Cruor99 that aims to teach you how to use Vim and configure it. You can also fiddle with alexbooker’s dotfiles here.

We also have some useful tools/resources plugins for Vim listed for you. Check them out below.

A useful list of Tools/Plugins/Resources for Vim

  1. Thoughtful dotfiles

Thoughtful dotfiles is a great collection of dotfiles. You can go through the collection and use the most appropriate code for your project. If you are worried about mistakes, always remember that experimentation is the key here.

Cmizony on Livecoding.tv uses Vim regularly in this development. He also wants you to become the next Vim ninja.

Check out his amazing in-depth project to know about how to become Vim expert. He also shares his ideas on fiddling with other’s .vimrc files for learning purposes.

  1. Base 16 Vim

Base 16 is a color scheme and a template system at the same time. It offers sixteen colors. You can use Base 16 vim to configure your Vim color scheme. It supports both graphical and the console Vim.

To enable syntax highlighting, you can use the following command in your terminal.

cd ~/.vim/colors

git clone git://github.com/chriskempson/base16-vim.git base16

cp base16/colors/*.vim
  1. Vundle

Vundle is a Vim plugin manager that can make your life easier. It not only keeps track of all the plugins and configurations in .vimrc, but also helps you to install and update configured plugins on the fly. Other key features include searching Vim scripts, clean unused plugins and ensure that you don’t have to type in the whole command by providing single keypresses in interactive mode.

Conclusion

Vim is a powerful text editor. Learning how to customize the dotfile associated with Vim can help you a lot in your current and future projects. For those who are new to the whole idea of Vim and dotfiles might find Vim intimidating. But, don’t be afraid as there are many elite broadcasters who develop complex projects using Vim. A prime example would be the Halo 5 map analysis tool project that utilizes Vim extensively. The project is carried out by godlyperfection. Don’t forget to check his streams to learn more about Vim and its usage.

So, are you ready to configure your Vim text editor now? Let us know in the comment section below and also share your customization ideas with us! We are eager to hear from you.

Dr. Michael J. Garbade

I, Dr. Michael J. Garbade is the co-founder of the Education Ecosystem (aka LiveEdu), ex-Amazon, GE, Rebate Networks, Y-combinator. Python, Django, and DevOps Engineer. Serial Entrepreneur. Experienced in raising venture funding. I speak English and German as mother tongues. I have a Masters in Business Administration and Physics, and a Ph.D. in Venture Capital Financing. Currently, I am the Project Lead on the community project -Nationalcoronalvirus Hotline I write subject matter expert technical and business articles in leading blogs like Opensource.com, Dzone.com, Cybrary, Businessinsider, Entrepreneur.com, TechinAsia, Coindesk, and Cointelegraph. I am a frequent speaker and panelist at tech and blockchain conferences around the globe. I serve as a start-up mentor at Axel Springer Accelerator, NY Edtech Accelerator, Seedstars, and Learnlaunch Accelerator. I love hackathons and often serve as a technical judge on hackathon panels.

View Comments

  • Vim IS quite intimidating and it seems to possess a steep learning curve. If you want to learn Vim in small, easy-to-swallow bites checkout Vim-A-Min (www.vimamin.com)

    • Hey Thom,

      Vim does have a steep learning curve, but it pays off in a long run. Also, the site you provided is good, but requires users to register to even use! That's a let down!

      • In an effort to "give back" and as a mirror to the way in which I have become comfortable and proficient with VIM I developed Vim-A-Min. It is daily exercises in Vi(m) to help strengthen your ability (and confidence) in small doses.
        vimamin.com is absolutely free and offered as a service to the community.

  • I found this guide to be very thorough in creating a vim dot file....excellent information

  • Thanks for the guide! Now, I think I am able to use Vim with confidence and configure it accordingly.

Recent Posts

Blockchain in Elections: A Leap Toward Transparent Democracy

In 2024 we're witnessing a critical point in democratic technology: the integration of blockchain and…

3 weeks ago

Win Big with Our Amazon Fire Max 11 & AirPods Pro Giveaway!

We’re thrilled to announce an exciting opportunity for you to win not one but two…

2 months ago

Unleashing Potential: How Education Ecosystem Transforms Learning into Real-World Success

Acquiring practical skills is crucial for career advancement and personal growth. Education Ecosystem stands out…

4 months ago

The Role of Artificial Intelligence in Modern Software Development

Artificial Intelligence (AI) has been making significant strides in various industries, and the software development…

7 months ago

Highest Stable Coin Yields – (W16 – 2024)

Another week to bring you the top yield platforms for three of the most prominent…

8 months ago

LEDU Token OTC Trading

If you hold a large volume of LEDU tokens above 1 million units and wish…

9 months ago