Created
November 6, 2022 12:09
-
-
Save gsrai/b6986a542b6b63c98351c393b5739495 to your computer and use it in GitHub Desktop.
Basic .vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set termguicolors | |
" Set compatibility to Vim only. | |
" be vim no vi. | |
set nocompatible | |
" Disable the default Vim startup message. | |
set shortmess+=I | |
" Helps force plug-ins to load correctly when it is turned back on below. | |
filetype off | |
" Turn on syntax highlighting. | |
syntax on | |
" For plug-ins to load correctly. | |
filetype indent plugin on | |
" Turn off modelines | |
set modelines=0 | |
" Automatically wrap text that extends beyond the screen length. | |
set wrap | |
" Vim's auto indentation feature does not work properly with text copied from outside of Vim. Press the <F2> key to toggle paste mode on/off. | |
nnoremap <F2> :set invpaste paste?<CR> | |
imap <F2> <C-O>:set invpaste paste?<CR> | |
set pastetoggle=<F2> | |
" Uncomment below to set the max textwidth. Use a value corresponding to the width of your screen. | |
" set textwidth=79 | |
set formatoptions=tcqrn1 | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
set noshiftround | |
set autoindent | |
" Display 5 lines above/below the cursor when scrolling with a mouse. | |
set scrolloff=5 | |
" Fixes common backspace problems | |
set backspace=indent,eol,start | |
" Speed up scrolling in Vim | |
set ttyfast | |
" Status bar | |
set laststatus=2 | |
" Display options | |
set showmode | |
set showcmd | |
set showmatch | |
" Highlight matching pairs of brackets. Use the '%' character to jump between them. | |
set matchpairs+=<:> | |
" Display different types of white spaces. | |
set list | |
set listchars=tab:›\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨ | |
" Show line numbers | |
set number | |
set relativenumber | |
" Set status line display | |
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ [BUFFER=%n]\ %{strftime('%c')} | |
" Encoding | |
set encoding=utf-8 | |
" Highlight matching search patterns | |
set hlsearch | |
" Enable incremental search | |
set incsearch | |
" Include matching uppercase words with lowercase search term | |
set ignorecase | |
" Include only uppercase words with uppercase search term | |
set smartcase | |
" Store info from no more than 100 files at a time, 9999 lines of text, 100kb of data. Useful for copying large amounts of data between files. | |
set viminfo='100,<9999,s100 | |
" Map the <Space> key to toggle a selected fold opened/closed. | |
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR> | |
vnoremap <Space> zf | |
" Automatically save and load folds | |
autocmd BufWinLeave *.* mkview | |
autocmd BufWinEnter *.* silent loadview" | |
set ai | |
set ruler | |
highlight Comment ctermfg=green | |
" By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't | |
" shown in any window) that has unsaved changes. This is to prevent you from " | |
" forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find | |
" hidden buffers helpful enough to disable this protection. See `:help hidden` | |
" for more information on this. | |
set hidden | |
" Unbind some useless/annoying default key bindings. | |
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this. | |
" Disable audible bell because it's annoying. | |
set noerrorbells visualbell t_vb= | |
" Enable mouse support. You should avoid relying on this too much, but it can | |
" sometimes be convenient. | |
set mouse+=a | |
" Try to prevent bad habits like using the arrow keys for movement. This is | |
" not the only possible bad habit. For example, holding down the h/j/k/l keys | |
" for movement, rather than using more efficient movement commands, is also a | |
" bad habit. The former is enforceable through a .vimrc, while we don't know | |
" how to prevent the latter. | |
" Do this in normal mode... | |
nnoremap <Left> :echoe "Use h"<CR> | |
nnoremap <Right> :echoe "Use l"<CR> | |
nnoremap <Up> :echoe "Use k"<CR> | |
nnoremap <Down> :echoe "Use j"<CR> | |
" ...and in insert mode | |
inoremap <Left> <ESC>:echoe "Use h"<CR> | |
inoremap <Right> <ESC>:echoe "Use l"<CR> | |
inoremap <Up> <ESC>:echoe "Use k"<CR> | |
inoremap <Down> <ESC>:echoe "Use j"<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment