Last active
September 28, 2024 10:18
-
-
Save ffimnsr/945c55908a187a61a50ee67f2e6cacf7 to your computer and use it in GitHub Desktop.
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
" Put in ~/.vimrc and on /etc/vimrc.local (fedora) | |
" Set file encoding to UTF-8 always | |
scriptencoding utf-8 | |
set encoding=utf-8 | |
" Set map leader | |
let mapleader=',' | |
" Set shell | |
let shell='/bin/bash' | |
" Don't use vim compatibility | |
set nocompatible | |
" Sets how many lines of history VIM has to remember | |
set history=1000 | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" Set shortmessage options | |
set shortmess=at | |
" Sets the height of the command bar | |
set cmdheight=1 | |
" Toggle paste mode on and off | |
set pastetoggle=<F3> | |
" Enable wrap | |
set wrap | |
" Disable file backup | |
set nobackup | |
set nowritebackup | |
set noswapfile | |
" Expand tab to spaces | |
" And set the tab stop to 2 | |
set shiftwidth=2 | |
set tabstop=2 | |
set softtabstop=2 | |
set expandtab | |
" Always show current cursor line | |
set cursorline | |
" Always display the status line | |
set laststatus=2 | |
" Display incomplete commands | |
set showcmd | |
" 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 mat=2 | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
" Do incremental search and highlight the search word | |
set incsearch | |
set hlsearch | |
" Ignore case when searching | |
" And when searching try to be smart about cases | |
set ignorecase | |
set smartcase | |
" Enable line numbers | |
" And show relative number to current line | |
set number | |
set numberwidth=5 | |
set relativenumber | |
" For regular expressions turn magic on | |
set magic | |
" Disable error bells and visual bells | |
set novisualbell | |
set noerrorbells | |
set t_vb= | |
set tm=500 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
" Enable code folding | |
set foldenable | |
set foldlevelstart=10 | |
set foldnestmax=10 | |
set foldmethod=indent | |
" Configure backspace so it acts as it should act | |
set backspace=indent,eol,start | |
set whichwrap+=<,>,h,l | |
" Display extra whitespace | |
set list | |
set listchars=tab:›\ ,trail:.,nbsp:· | |
" Open new split panes to right and bottom, which feels more natural | |
set splitbelow | |
set splitright | |
" Vanilla completion | |
set completeopt=longest,menuone | |
" Enable filetype plugin and omnifunc | |
filetype plugin on | |
au filetype css setlocal omnifunc=csscomplete#CompleteCSS | |
au filetype html setlocal omnifunc=htmlcomplete#CompleteTags | |
" Add current path to runtime path | |
set rtp+=$PWD | |
" Display tab at top all the time | |
set showtabline=2 | |
" Show only 4 tabs at max | |
set tabpagemax=4 | |
" Always use vertical diffs | |
set diffopt+=vertical | |
" Turn on wild menu | |
set wildmenu | |
set wildignore+=*.o,*.out,*.obj,.git,.class,.svn | |
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.tar.xz,*.rar,*.tgz | |
set wildignore+=*.swap,*~,._* | |
set wildignore+=*/.git/*,*/tmp/*,*.swp | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern | |
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") | |
syntax on | |
endif | |
" Show where the 80 character is | |
set textwidth=80 | |
set colorcolumn=+1 | |
" Disable viminfo | |
set viminfo= | |
" Set grep to use ripgrep | |
if executable('rg') | |
set grepprg=rg\ --color=never | |
endif | |
" Quicker window movement | |
map <C-h> <C-w>h | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-l> <C-w>l | |
" Open the quick buffer | |
map <leader>ew :e %% | |
" Open tab with buffer | |
map <leader>et :tabe %% | |
" Split with buffers | |
map <leader>esh :sp %% | |
map <leader>esv :vsp %% | |
" Reload buffers | |
map <leader>rr :bufdo :e!<CR> | |
" Move between buffers | |
map <leader>l :bnext<CR> | |
map <leader>h :bprevious<CR> | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><space> :noh<CR> | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Fast saving | |
nmap <leader>w :w!<cr> | |
" Alternative to key shortcut saving and quit | |
nmap <silent> <F2> :w<CR> | |
nmap <silent> <F4> :q<CR> | |
" Open vimrc in new tab | |
nmap <leader>v :tabe $MYVIMRC<CR> | |
nmap <leader>n :tabe<CR> | |
nmap <leader>. :tabn<CR> | |
nmap <leader>/ :tabn<CR> | |
" Command :W sudo saves the file | |
" (useful for handling the permission-denied error) | |
" command! W execute 'w !sudo tee % > /dev/null' <bar> edit! | |
" Write command same as :w | |
command! W write | |
" Change working directory using cwd command | |
cmap cwd lcd %:p:h | |
" Alternative to the above saving method for sudo | |
cmap w!! w !sudo tee % >/dev/null | |
" Make it so ; works like : for commands | |
nnoremap ; : | |
" Short for fold all | |
nnoremap <space> za | |
" Disable search highlight using ESC same as a | |
nnoremap <esc> :noh<return><esc> | |
" Wrapped lines goes down/up to next row instead of next line | |
nnoremap j gj | |
nnoremap k gk | |
" Enable visual shift | |
vnoremap < <gv | |
vnoremap > >gv | |
" Back to normal mode on . press | |
vnoremap . :normal .<CR> | |
" Set NetRW options | |
let g:netrw_liststyle=3 | |
let g:netrw_banner=0 | |
let g:netrw_browse_split=4 | |
let g:netrw_altv=1 | |
let g:netrw_winsize=25 | |
" Theming vim | |
if !has('gui_running') | |
set t_Co=256 | |
set background=dark | |
colorscheme slate | |
endif | |
" Load local config | |
if filereadable($HOME . "/.vimrc.local") | |
source ~/.vimrc.local | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment