Minium Workable Mvp Vimrc
”—————————————————————- “ 4. User interface “—————————————————————- “ Set X lines to the cursor when moving vertically set scrolloff=0
” Always show mode set showmode
” Show command keys pressed set showcmd
” Enable the WiLd menu set wildmenu
” Show the current position set ruler
” Command bar height set cmdheight=2
” Backspace works on Insert mode set backspace=eol,start,indent
” Don’t redraw while executing macros (good performance config) set lazyredraw
” Show matching brackets when text indicator is over them set showmatch
” How many tenths of a second to blink when matching brackets set matchtime=2
” No annoying sound on errors set noerrorbells set novisualbell
” Mouse set mouse=a
” Highlight cursor line and cursor column set cursorline set nocursorcolumn
” Always show the status line set laststatus=2
” Change the cursor shape if !has(“nvim”) let &t_SI = “<Esc>[6 q” let &t_SR = “<Esc>[4 q” let &t_EI = “<Esc>[2 q” else set guicursor=n-v:block-Cursor/lCursor-blinkon0 set guicursor+=i-ci-c:ver100-Cursor/lCursor-blinkon0 set guicursor+=r-cr:hor100-Cursor/lCursor-blinkon0 endif
” Omni completion if has(‘autocmd’) && exists(‘+omnifunc’) autocmd Filetype * \ if &omnifunc == “” | \ setlocal omnifunc=syntaxcomplete#Complete | \ endif endif
” Fix italics issue if !has(“nvim”) let &t_ZH=”\e[3m” let &t_ZR=”\e[23m” endif
”—————————————————————- “ 5. Scheme and colors “—————————————————————- “ True color “ if !has(“nvim”) “ if has(“termguicolors”) “ let &t_8f = “<Esc>[38;2;%lu;%lu;%lum” “ let &t_8b = “<Esc>[48;2;%lu;%lu;%lum” “ set termguicolors “ endif “ else “ set termguicolors “ endif
” Syntax highlighting syntax enable
” Color scheme colorscheme atomic
” Show syntax highlighting groups
nnoremap
”—————————————————————- “ 6. Files and backup “—————————————————————- “ Disable swap files set noswapfile
” No backup (use Git instead) set nobackup
” Prevents automatic write backup set nowritebackup
” Use UTF-8 as default encoding set encoding=utf8
” Use Unix as the standard file type set fileformats=unix,dos,mac
” Autoread a file when it is changed from the outside set autoread
” Reload a file when it is changed from the outside
let g:f5msg = ‘Buffer reloaded.’
nnoremap
” Enable filetype plugins filetype plugin on filetype indent on
” Allow us to use Ctrl-s and Ctrl-q as keybinds “ Restore default behaviour when leaving Vim. if !has(“nvim”) silent !stty -ixon autocmd VimLeave * silent !stty ixon endif
” Save the current buffer
nnoremap
” Save all buffers
nnoremap
” :W sudo saves the file “ (useful for handling the permission-denied error) cnoremap WW w !sudo tee > /dev/null %
” Rename file
nnoremap
” Work on buffer
nnoremap yab :%y
”—————————————————————- “ 7. Buffers management “—————————————————————- “ Buffer hidden when it is abandoned set hidden
” Close the current buffer
nnoremap
” Move between buffers
nnoremap
” Edit and explore buffers
nnoremap
” Switch CWD to the directory of the current buffer
nnoremap
” Copy the filepath to clipboard
nnoremap
” Ignore case when autocompletes when browsing files set fileignorecase
” Specify the behavior when switching between buffers try set switchbuf=useopen,usetab,newtab set showtabline=2 catch endtry
” Remember info about open buffers on close “ set viminfo^=%
”—————————————————————-
“ 8. Tabs management
“—————————————————————-
“ Create and close tabs
nnoremap
” Open a new tab with the current buffer’s path
“ Useful when editing files in the same directory
nnoremap
” Move tabs position
nnoremap
”—————————————————————-
“ 9. Multiple windows
“—————————————————————-
“ Remap wincmd
map
set winminheight=0 set winminwidth=0 set splitbelow set splitright set fillchars+=stlnc:\/,vert:│,fold:―,diff:―
” Split windows
map
” Resize windows
if bufwinnr(1)
map + :resize +1
” Toggle resize window
nnoremap
” Last, previous and next window; and only one window
nnoremap
” Move between Vim windows and Tmux panes
“ - It requires the corresponding configuration into Tmux.
“ - Check it at my .tmux.conf from my dotfiles repository.
“ - URL: https://github.com/gerardbm/dotfiles/blob/master/tmux/.tmux.conf
“ - Plugin required: https://github.com/christoomey/vim-tmux-navigator
if !has(“nvim”)
set
nnoremap
” Remove the Windows ^M - when the encodings gets messed up
noremap
” Close the preview window
nnoremap
” Scroll the preview window
if !has(“nvim”)
set
nnoremap
”—————————————————————- “ 10. Indentation tabs “—————————————————————- “ Enable autoindent & smartindent set autoindent set smartindent
” Use tabs, no spaces set noexpandtab
” Be smart when using tabs set smarttab
” Tab size (in spaces) set shiftwidth=2 set tabstop=2
” Remap indentation
nnoremap
vnoremap
inoremap
” Don’t show tabs set list
let g:f6msg = ‘Toggle list.’
nnoremap
” Show tabs and end-of-lines set listchars=tab:│\ ,trail:¬
”—————————————————————- “ 11. Moving around lines “—————————————————————- “ Specify which commands wrap to another line set whichwrap+=<,>,h,l
” Many jump commands move the cursor to the start of line set nostartofline
” Wrap lines into the window set wrap
” Don’t break the words “ Only works if I set nolist (F6) set linebreak set showbreak=├——»
” Stop automatic wrapping set textwidth=0
” Column at 80 width set colorcolumn=80
” Listings don’t pause set nomore
” Color column
let g:f10msg = ‘Toggle colorcolumn.’
nnoremap
” Show line numbers set number set numberwidth=2
let g:f3msg = ‘Toggle line numbers.’
nnoremap
” Set relative line numbers set relativenumber
let g:f4msg = ‘Toggle relative line numbers.’
nnoremap
” Treat long lines as break lines (useful when moving around in them)
nnoremap
vnoremap
nnoremap
vnoremap
” Toggle the cursor position start/end of the line
nnoremap
” Join / split lines
nnoremap
” Duplicate a line nnoremap cx yyP nnoremap cv yyp
” Folding set foldmethod=marker
” Return to last edit position when opening files autocmd BufReadPost * \ if line(“’"”) > 0 && line(“’"”) <= line(“$”) | \ exe “normal! g`"” | \ endif
” — Readline commands —
“—————————————————————-
“ Move the cursor to the line start
inoremap
” Move the cursor to the line end
inoremap
” Moves the cursor back one character
inoremap
” Moves the cursor forward one character
inoremap
” Remove one character
inoremap
” Command Mode
cnoremap
cnoremap
”—————————————————————- “ 12. Paste mode “—————————————————————- “ Bracketed paste mode “ - Source: https://ttssh2.osdn.jp/manual/en/usage/tips/vim.html if !has(“nvim”) if has(“patch-8.0.0238”) if &term =~ “screen” let &t_BE = “\e[?2004h” let &t_BD = “\e[?2004l” exec “set t_PS=\e[200~” exec “set t_PE=\e[201~” endif endif endif
”—————————————————————- “ 13. Search, vimgrep and grep “—————————————————————- “ Highlight search results set hlsearch
” Makes search act like search in modern browsers set incsearch
” Search, wrap around the end of the buffer set wrapscan
” Ignore case when searching set ignorecase
” When searching try to be smart about cases set smartcase
” For regular expressions turn magic on set magic
” Maximum amount of memory in Kbyte used for pattern matching set maxmempattern=1000
” — Highlight —
“—————————————————————-
“ Map
” Highlight the word under the cursor and don’t jump to next
nnoremap
” Highlight the selected text and don’t jump to next
vnoremap
” Disable highlight
nnoremap
” Search into a Visual selection
vnoremap