IDE and text-editor is the essential tools for programmers. and, as you know, there are so many text editor out there. There are Notepad ++, Visual Studio Code, Sublime Text, Atom, Brackets, etc. But, i and many people out there choose Vim as our text editor, since it is highly customizable for our programming purpose.
What Is Vim ?
For those of you who don't know, Vim is a text editor, not an IDE. but, don't get me wrong. Vim is more than just a text editor. We can make Vim works like an IDE. i wouldn't explain what makes Vim special here. you can watch about that in this video :
Altough Vim is very good for coding, it doesn't look like that at the first time. When you first installed vim and open it, it will look like this :
not bad, right? but, since we will using Vim as our main text editor, we need a better view. this is my Vim text editor after configuring it :
So, how do we make vim looks better ? here is some configuration for vim that i think are important :
Auto Indent
auto indenting feature is so important if you are writing code in programming languages that care about indenting, likes python. to enable auto-indent feature, you can type :set ai in normal mode. if you want this feature enable for every file you create, you can add set ai (without colon) in your _vimrc file (for windows user).
Syntax Highlighting
for some coder, syntax highlighting is an important feature. syntax highlighting feature makes us understand the code easier. to enable syntax highlighting in vim, open your _vimrc file, and add this text : syntax on.
Turn Off The Bell
When you are using Vim for the first time, you will notice that there is a bell sound when something wrong happen. for me, this is so annoying. to turn off this sound, add set belloff=all to your _vimrc file.
Line Numbering
to display line number in Vim, add set number to your _vimrc file. if you want relative numbering, add set relativenumber to your _vimrc file.
Matching Brackets and Quotation Marks
when you use VS Code, Atoms, and other text editor, when you type (, you will see that ) also appears automatically. But, when you use Vim, you wouldn't see this feature by default. to enable this feature, add inoremap ( ()<Esc>i to your _vimrc file. you can do the same thing with quotation marks. So, to enable this feature for every brackets and quotation marks, add this code to your _vimrc file :
Themes in Vim are called as colorscheme. After installing vim, you will also get some Theme/Colorscheme by default. to change the colorscheme that applied in vim, type :colors an then press tab button. then you will see something like this :
this is the menu for choosing vim colorscheme. you can use arrow keys to navigate between it and press enter to applied that colorscheme. to add new colorscheme, you can search it in github. the coloscheme that i personally use is material colorscheme. to use this colorscheme, download the file in colors folder and place it to vim82 -> colors in your vim folder. after that, you can applied that colorscheme like usual.
Vim Built-in Autocompletion
do you think vim can't perform autocompletion? Vim have its built-in autocompletion named Omni Completion.
Omni completion provides smart autocompletion for programs. When invoked, the text before the cursor is inspected to guess what might follow. A popup menu offers word completion choices that may include struct and class members, system functions, and more. A similar feature in Microsoft Visual Studio is known as IntelliSense. - Vim Fandom
to enable this feature, open your _vimrc file, and write :
after this step, you can start typing your code. if you want the code suggestion to pop-up, press ctrl-x and ctrl-o.
Cool Statusbar
the cool yellow line in the bottom of my Vim at the screenshot above is called statusbar. there are some plugins that you can use to make your statusbar looks better. for example, vim airline and vim lightline. I myself use vim airline for my statusbar. to install this plugin, you can use some plugin-manager that you prefer, like vundle or vim-plug. but, if you use Vim 8, you can use vim native package manager. to install vim airline using vim native package manager, do this step :
download the entire repository in zip file format.
extract this zip file
go to you vim folder, and open vimfiles folder, and open start folder (if you don't see this folder, then create it).
place the extracted zip file to this start folder.
done. you already have install vim airline.
after that step, your vim statusbar better. you can also add this code to your _vimrc file (optional). i don't know what exactly this code does, but it looks like this code make your statusbar display the file extension and current time.
The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations.
Installation
Use your favorite plugin manager to install this plugin. tpope/vim-pathogen, VundleVim/Vundle.vim, junegunn/vim-plug, and Shougo/dein.vim are some of the more popular ones. A lengthy discussion of these and other managers can be found on vi.stackexchange.com. Basic instructions are provided below, but please be sure to read, understand, and follow all the safety rules that come with your power tools plugin manager.
If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: Vim screencast #75: Plugin managers.
Pathogen
Pathogen is more of a runtime path manager than a plugin manager. You must…
Installation for this plugin is the same to the installation vim airline plugin. after installing this plugin, you can open file explorer using :NERDTree command in normal mode.
Better Syntax Highlinghting for Python
As i said before, vim have built-in syntax highlighting feature. but, it is not too good. if you want a better syntax highlighting for python, you can use this plugin :
the installation of this plugin is the same to the installation vim airline plugin. after installing, you can use this plugin by add this code to your _vimrc file :
letg:python_highlight_all=1
Terminal
you can open your terminal directly in Vim text editor. you don't need to install anything. to open terminal in vim, type :terminal or :term in normal mode.
Running Python Code
actually, you can run python code in vim using terminal and type python example.py. but, if you want to run python code by pressing keyboard, then follow this step. first, open you _vimrc file. then, write this code:
nnoremap <F10>:!python %<CR>
what this code does is mapping f10 key to run :! python %<CR> command. in general, the command :! python %<CR> will take the name of your file using symbol % and then run it like you run it manually in the terminal. after this step, you can run python code by pressing f10 on your keyboard. Do you know what to do if you want to run python code by pressing r key ? yes, just write nnoremap r :! python %<CR>.
So, that is some configuration to make vim looks like an IDE. i know that there are other IDE features that vim doesn't have, like debugger. but, you can give a try for vim. Oh, wait. can this plugin be called a debugger? I've never tried it.