Installing Vim if you don’t have it in your system
# All these commands will get you vim installed. But, you should stick to the
# one you want or like.
sudo apt install vim # version 2:8.2.3995-1ubuntu2, or
sudo apt install vim-tiny # version 2:8.2.3995-1ubuntu2
sudo apt install neovim # version 0.6.1-3
sudo apt install vim-athena # version 2:8.2.3995-1ubuntu2
sudo apt install vim-gtk3 # version 2:8.2.3995-1ubuntu2
sudo apt install vim-nox # version 2:8.2.3995-1ubuntu2
In your home directory create the config file for vim
# will go home
cd ~
# will create that file called '.vimrc'
touch .vimrc
Inside that file add these commands
" Vim configuration file "
" enable mouse support "
set mouse=a
" enable syntax "
syntax on
" enable line numbers "
set number
" highlight current line "
set cursorline
:highlight Cursorline cterm=bold ctermbg=black
" enable highlight search pattern "
set hlsearch
" enable smartcase search sensitivity "
set ignorecase
set smartcase
" Indentation using spaces "
" tabstop: width of tab character
" softtabstop: fine tunes the amount of whitespace to be added
" shiftwidth: determines the amount of whitespace to add in normal mode
" expandtab: when on use space instead of tab
" textwidth: text wrap width
" autoindent: autoindent in new line
set tabstop =4
set softtabstop =4
set shiftwidth =4
set textwidth =79
set expandtab
set autoindent
" show the matching part of pairs [] {} and () "
set showmatch
" remove trailing whitespace from Python and Fortran files "
autocmd BufWritePre *.py :%s/\s\+$//e
autocmd BufWritePre *.f90 :%s/\s\+$//e
autocmd BufWritePre *.f95 :%s/\s\+$//e
autocmd BufWritePre *.for :%s/\s\+$//e
" enable color themes "
if !has('gui_running')
set t_Co=256
endif
" enable true colors support "
set termguicolors
" Vim colorscheme "
colorscheme desert
"-------------------------------------------------------------"
"Bonus. " Find & Replace (if you use the ignorecase, smartcase these are mandatory) "
" :%s/<find>/<replace>/g "replace global (e.g. :%s/mass/grass/g)"
" :%s/<find>/<replace>/gc "replace global with confirmation"
" :%s/<find>/<replace>/gi "replace global case insensitive"
" :%s/<find>/<replace>/gI "replace global case sensitive"
" :%s/<find>/<replace>/gIc "replace global case sensitive with confirmation"
" " Vim (book)marks "
" mn "replace n with a word A-Z or number 0-9"
" :'n "go to mark n"
" :`. "go to the last change"
" :marks "show all declared marks"
" :delm n "delete mark n"
" " Delete range selection "
" :<line_number>,<line_number>d "(e.g. :2,10d deletes lines 2-10)"
" " LaTeX shortcuts "
" nnoremap <F1> :! pdflatex %<CR><CR>
" nnoremap <F2> :! bibtex $(echo % \| sed 's/.tex$//') & disown<CR><CR>
" nnoremap <F3> :! evince $(echo % \| sed 's/tex$/pdf/') & disown<CR><CR>
" nnoremap <F4> :! rm *.log *.aux *.out *.blg & disown<CR><CR>
Download .vimrc file
vimrc2.4KB