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 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?
ENJOYING THIS POST?
Get 5% discount on your monthly subscription purchase
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 Overlay Your Chat On Screen
- 10 Habits and Things Only Computer Programmers Know
- A Programming Instructor HTML-CSS Connecticut
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 starts 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 on 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.
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.
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 few hours.
So, how it’s done?
Let’s see some examples of Vim dotfile configurations.
- 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.
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.
- 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 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, alexbooker 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.
Useful list of Tools/Plugins/Resources for Vim
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.
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.
git clone git://github.com/chriskempson/base16-vim.git base16
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.
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.