Vim Plugin Manager
Installation
Download it from its GitHub repository or the risky but easy way using curl:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Adding Plugins
Add a plugin section to the .vimrc
:
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
" Gruvbox Theme
Plug 'sainnhe/gruvbox-material'
" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
Afterwards reload the .vimrc and run :PlugInstall
in vim to install the plugins (e.g. gruvbox-material)
Display Whitespace Characters in Vim
Turn on:
:set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣
:set list
Turn off:
:set nolist
Highlight current Line and current Column
:set cursorline
:set cursorcolumn
Change Colorscheme
:colorscheme <TAB>
Search and replace
Global search and replace (g
), ignoring case (i
)
:%s/SEARCH/replace/gi
Copy and paste multiple lines
-
Shift + v to enter visual mode
-
select lines
-
y for copy or x to cut
-
p to paste at cursor position
Select from cursor
-
vim (enter the visual mode) and use cursor to select characters to copy/cut
Search for word at cursor position
*
Allow Editing
Needed e.g. for vimdiff in git
:set noro
" Default to not read-only in vimdiff
set noro
My vimrc
Sets ..
-
no read-only (e.g. for vimdiff)
-
display line numbers (global line numbers, not relative)
-
syntax highlight on
-
file type detection on
" Default to not read-only in vimdiff
set noro
set number
set cursorline " highlight current line
set cursorcolumn " highlight current column, must have for yaml
syntax on
filetype on
set et " expandtab (use space character when tab key used) *
set ts=2 " tabstop *
set sw=2 " shiftwidth *
set sts=2 " softtabstop (Let backspace delete indent **
set ai " autoindent (Indent at the same level of the previous line)
set si " smart indent
set hls " highlightsearch (Highlight search terms)
set ic " ignorecase when searching in vim
syntax on " syntax highlighting
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
" Gruvbox Theme
Plug 'sainnhe/gruvbox-material'
" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
colorscheme gruvbox-material
Indent selected Text Blocks
Better set :set shiftwidth=2 in the .vimrc
|
-
Select text block using Shift+V (virtual mode) and UP and DOWN to select multiple lines
-
Press < or > for indenting the block in the left or right direction, to repeat the action, press .