Vim as IDE

Vim is a powerful text editor with numerous functions (Vi IMproved), as the name suggests, Vim is Improved.

There is the default text editor in UNIX and Unix-like systems, its use mode is complex for beginners, but it is possible to learn to use Vim in less than a week and learn the basic commands with VimTutor.

$ vimtutor

We can also get GVim for the GUI mode

$ gvim

Which usually needs to be downloaded from its own package manager.

Why vim?

Vim as already mentioned has 3 mode of use: command, visual and insertion, it is particularly versatile and when you take your hand with the keyboard it is very fast to use (example ... I just give 'd' twice to delete a line, or use the 'h', 'j', 'k', 'l' keys to move through the text file (in command mode), replace a letter using 'r', delete a letter using 'x', enter text immediately below or above a line, respectively, 'o' / 'O'.

Moreover, Vim supports the highlighting of several programming languages, starting from C, to Objective-C, from Python to Go, Ruby, Lua, Haskell, etc ... It also supports the highlighting of configuration files such as the ApacheConf or the configuration of a Samba server ... Files with the * .conf extension in general have a highlight.

It is possible to get lots of plugins to make it even better, Vim is scriptable to the max.

~ / .Vimrc

~ / .vimrc is a file located in $ HOME and contains the instructions that Vim needs to enable certain features or not, it is clear that they are simple commands that can also be executed by Vim himself (example):

~ / .vimrc ======= syntax on =======

is the same as giving the command

: syntax on

in Vim

In any case, let's get back to us ... I take my .vimrc which is very simple (.vimrc)

"Begin of vim config file set nocompatible" Not compatible with Vi settings "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" set backspace = indent , eol, start set nobackup "No backup set history = 50" keep 50 lines of command line history set ruler "show the cursor position all the time set showcmd" display incomplete commands set incsearch "do incremental searching set autoindent" indenting set showcmd set cursorline set tabstop = 2 set softtabstop = 2 set noswapfile "No swapfile set nowb set wildmenu set modeline set ls = 2 set number" left-side line counter set t_Co = 256color "Enable 256 colors terminal map Q gq syntax on" Enable syntax colorscheme pablo "pablo.vim color scheme filetype plugin indent on autocmd FileType text setlocal textwidth = 78" Language interpreter / compiler execution "C / GCC" Python / python - env ​​"Ruby / ruby" C ++ / G ++ / GCC-C ++ "Shell / sh autocmd FileType c map cc:! / usr / bin / gcc% -Wall -O2 -pipe -march = native -mtune = native && ./a.out autocmd FileType python map:! / usr / bin / env python% autocmd FileType ruby ​​map rbr:! / usr / bin / ruby% autocmd FileType cpp map cxx:! / usr / bin / g ++% -Wall -O2 -pipe -march = native -mtune = native && ./a.out autocmd FileType sh map shr:! / bin / sh% if has ('langmap') && exists ('+ langnoremap') set langnoremap endif "If mouse is availible enable it if has ('mouse') set mouse = a endif" End of vim config file

The key points are these:

syntax on "Enable syntax highlighting set cursorline" Enable a line indicating where the cursor is set tabstop = 2 "Space of the tab set ls = 2 set modeline" Statusbar set number "Counters on the left set t_Co = 256color" Terminals at 256 colors colorscheme pablo "Color scheme for filetype plugin indent on syntax" For * .c files, link 'cc' to compile command with gcc autocmd FileType c map cc:! / usr / bin / gcc% -Wall -O2 -pipe -march = native -mtune = native && ./a.out "For * .py files connect 'pyr' to the file interpretation command autocmd FileType python map pyr:! / usr / bin / env python%" 'rbr' -> Interpretation autocmd FileType ruby ​​map rbr:! / usr / bin / ruby% "'cxx' -> Compile && Binary execution autocmd FileType cpp map cxx:! / usr / bin / g ++% -Wall -O2 -pipe -march = native -mtune = native && ./a.out "'shr' -> Interpretation autocmd FileType sh map shr:! / bin / sh%" The '%' indicates to use the file itself "autocmd FileType (extension) map (tas ti):! [command]%

It is also possible to activate the completion with CONTROL + N


NERDTree
NERDTree is a plugin for Vim able to display the directory tree ... Useful in case we are writing more modules.

Vim command:

: NERDTree

NERDTree: Vim.org
To install NERDTree:

  • Unzip the zipfile
  • Move nerdtree_plugin / to ~ / .vim
  • Move plugin / * to ~ / .vim / plugin
  • Move syntax / * to ~ / .vim / syntax


Powerline, Advanced Statusbar for Vim
To install powerline I suggest you follow this guide

We see the 'NORMAL' mode, that is the Command mode, the type of file (UNIX (posix)), the recognized language, as a percentage what is missing at the end of the file ... And more 🙂

nerdtree_powerline_edited
c.vim
is an essential plugin for any C / C ++ / C # / Objective-C / Objective-C ++ / ... programmer
Helps to insert comments (at the beginning it is possible to personalize a comment with all the data [filename, author, description, last update ...]), declarations, improve completion etc ...

You can see the features here.
Also from the link above we can download the plugin 🙂
How to install C.Vim:

  • Unzip the zipfile
  • Copy autoload / * to ~ / .vim / autoload
  • Copy c-support / in ~ / .vim
  • Copy ftplugin / * to ~ / .vim / ftplugin
  • Copy plugin / * to ~ / .vim / plugin
  • Copy syntax / * to ~ / .vim / syntax

It is also possible to customize the templates (initial comments for example) by editing the files in ~ / .vim / c-support / templates / *. Template

cvim_edited


Version Control System plugin (vcscommand)
Another important aspect is that of the VCS, or the version control system, we will use vcscommand (here).
VCSCommand (vcscommand.vim) supports the following VCS:

  • CVS
  • SVN
  • SVK
  • Go
  • Hg
  • Bzr

Mercurial is missing ... however there may be some other plugins specifically for this VCS.
So you can use this plugin to pushare changes, check the status of repositories, commit etc ...
To install the plugin:

  • Unzip the zipfile
  • Copy plugin / * to ~ / .vim / plugin
  • Copy syntax / * to ~ / .vim / syntax

I suggest reading doc / vcscommand.txt for commands 🙂


HTML / XML tag match
This is a nice plugin ... It seems of little importance, but it is very convenient ... let's imagine we find ourselves in a dozen tags ... Vim highlights the correspondence of the acute brackets, which is confusing ... why not use a plugin that highlights the whole tag?

  • Unzip the bz2 using the command: tar xfpj matchtag.tar.bz2
  • Copy ftplugin / * to ~ / .vim / ftplugin

html_tag_match_edited
Copy-cut-paste: easily copy / paste from the terminal buffer
This plugin is great for easily copying / pasting from the terminal buffer to the system clipboard (copy / paste)

Copy-cut-paste: here

  • Unzip the tarball
  • Copy plugin / * to ~ / .vim / plugin


VimTouch + Android pocket guide
I also wanted to inform you that the Vim runtime is also available for Android (ARM) platforms thanks to VimTouch, it is highly customizable ... Only you can use it anywhere! 🙂

Furthermore, an app is available that lists all Vim commands: Vim Reference

tmux
Tmux (Terminal MUltipleXer), finally, is a terminal multiplier and can be used for multiple instances of Vim together

Receive the latest posts by email

Enter the email and choose the inscriptions on the new page

tags:

InTheBit.it
Added devices
  • Compare Smartphone (0)
  • Compare Notebook (0)
Compare