VIM Configuration on Linux, Ubuntu, Windows 10 & 11

VIM Configuration & Setup on Linux, Ubuntu, Windows 11 and Windows 10

How to configure VIM with the latest Setup

VIM, a powerful and highly customizable text editor, is known for its efficiency, speed, and versatility. One of the key factors that sets VIM apart is its extensive configuration options, allowing users to tailor the editor to their specific needs and preferences. In this article, we will delve into the world of VIM configuration and guide you through the process of customizing VIM to enhance your text editing experience. By the end of this article, you'll have the knowledge and tools to transform VIM into your ideal editing environment.

  1. Understanding the VIM Configuration File:

VIM's configuration is primarily controlled through a file called “.vimrc,” located in your home directory. This file contains settings, key mappings, and plugin configurations that shape the behavior of VIM. Let's explore how you can harness the power of the “.vimrc” file.

  1. Basic Configuration Options:

The “.vimrc” file allows you to customize various aspects of VIM's behavior. Here are a few essential configurations to get you started:

  • Setting Options: You can modify VIM's behavior by setting various options. For example:
    • To enable line numbers, add the following line: set number.
    • To highlight syntax, use: syntax on.
    • To enable auto-indentation, add: set autoindent.
  • Key Mappings: VIM allows you to define custom key mappings to perform specific actions. For instance:
    • To map the F5 key to save the current file, add: map <F5> :w<CR>.
    • To map the Ctrl+S combination to save the file, use: map <C-S> :w<CR>.
  1. Plugin Managers:

VIM's extensibility is greatly enhanced by the availability of various plugins. To manage plugins effectively, you can use plugin managers. Here are a couple of popular plugin managers:

  • Vundle: Vundle is a straightforward and efficient plugin manager. To install Vundle, follow the instructions provided in its documentation. Once installed, you can specify your desired plugins in the “.vimrc” file using the Plugin command.
  • Pathogen: Pathogen simplifies the installation and management of VIM plugins. To use Pathogen, download the pathogen.vim script and place it in the “autoload” directory in your VIM configuration directory. Then, create a “bundle” directory and clone the plugins you wish to install into it.
  1. Essential Plugins:

While the choice of plugins depends on your specific needs, here are a few popular ones that can enhance your VIM experience:

  • NERDTree: NERDTree provides a file explorer sidebar within VIM, allowing you to navigate and manage your files seamlessly.
  • CtrlP: CtrlP offers a fast and efficient file finder that allows you to open files with minimal effort.
  • Syntastic: Syntastic provides real-time syntax checking, helping you identify and fix errors in various programming languages.
  • UltiSnips: UltiSnips is a powerful snippet engine that allows you to insert predefined code snippets with a few keystrokes, boosting your productivity.
  1. Online Resources and Communities:

As you dive deeper into VIM configuration, you'll likely encounter new ideas and techniques. Take advantage of the vast online resources and communities dedicated to VIM. Explore websites, forums, and online tutorials to discover new configurations, plugins, and tips shared by VIM enthusiasts worldwide.

Conclusion:

VIM's configurability is one of its greatest strengths, allowing you to create a personalized editing environment tailored to your needs. By understanding the “.vimrc” file, exploring configuration options, and utilizing plugin managers and plugins, you can unlock the full potential of VIM.

Embrace the opportunity to make VIM your own. Experiment with different settings, mappings, and plugins to create an editing environment that enhances your productivity and aligns with your workflow. With the power of VIM configuration in your hands, you'll be able to elevate your text editing experience to new heights.

mkdir -p ~/.vim ~/.vim/autoload ~/.vim/backup ~/.vim/colors ~/.vim/plugged

touch ~/.vimrc

vim ~/.vimrc

#Colors
cd ~/.vim/colors

curl -o molokai.vim https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim

:colorscheme molokai

” Disable compatibility with vi which can cause unexpected issues.
set nocompatible

” Enable type file detection. Vim will be able to try to detect the type of file is use.
filetype on

” Enable plugins and load plugin for the detected file type.
filetype plugin on

” Load an indent file for the detected file type.
filetype indent on

” Turn syntax highlighting on.
syntax on

” Add numbers to the file.
set number

” Highlight cursor line underneath the cursor horizontally.
set cursorline

” Highlight cursor line underneath the cursor vertically.
set cursorcolumn

” Set shift width to 4 spaces.
set shiftwidth=4

” Set tab width to 4 columns.
set tabstop=4

” Use space characters instead of tabs.
set expandtab

” Do not save backup files.
set nobackup

” Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10

” Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap

” While searching though a file incrementally highlight matching characters as you type.
set incsearch

” Ignore capital letters during search.
set ignorecase

” Override the ignorecase option if searching for capital letters.
” This will allow you to search specifically for capital letters.
set smartcase

” Show partial command you type in the last line of the screen.
set showcmd

” Show the mode you are on the last line.
set showmode

” Show matching words during a search.
set showmatch

” Use highlighting when doing a search.
set hlsearch

” Set the commands to save in history default number is 20.
set history=1000

” Enable auto completion menu after pressing TAB.
set wildmenu

” Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest

” There are certain files that we would never want to edit with Vim.
” Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx

” STATUS LINE ———————————————————— {{{

” Clear status line when vimrc is reloaded.
set statusline=

” Status line left side.
set statusline+=\ %F\ %M\ %Y\ %R

” Use a divider to separate the left side from the right side.
set statusline+=%=

” Status line right side.
“set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%%

” Show the status on the second to last line.
set laststatus=2

” }}}

#vim #linux #ubuntu

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button