Skip to content

Instantly share code, notes, and snippets.

@punitsoni
Last active August 12, 2020 21:49
Show Gist options
  • Save punitsoni/72e31e7ececcc25a3139a369cc6ac959 to your computer and use it in GitHub Desktop.
Save punitsoni/72e31e7ececcc25a3139a369cc6ac959 to your computer and use it in GitHub Desktop.
A good default vimrc without plugins
" -- General Options #general -----------------------------------------------{{{
" ---------------------------------------------------------------------------- "
set nocompatible
" Syntax highlighing on
syntax on
" Highlight search term as you type
set hlsearch
" Show current command in statusbar
set showcmd
" Enable mouse
set mouse=a
" Ignore case while searching
set ignorecase
" Do not create swap files
set noswapfile
" keep buffers loaded when window closes, required by many plugins.
set hidden
" Use spaces instead of tabs.
set expandtab
" Set default indentation size.
set tabstop=2
set shiftwidth=2
" Dont show mode as airline already does.
set noshowmode
" Default coding textwidth
set textwidth=80
" No automatic wrapping of lines.
set nowrap
" Use » to mark Tabs and ° to mark trailing whitespace
set list listchars=tab:»\ ,trail:°
" Enable line-numbers
set number
" Use non-retarded locations when opening new splits.
set splitbelow
set splitright
" Show completion options in a menu.
set wildmenu
" Use system clipboard
" set clipboard=unnamedplus
" Set the tab-completion for commands to be more similar to shell
set wildmode=longest:full,full
" Ignore these files / dirs when searchig/globbing
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pdf,*.msi,*.exe,*.a,*.o,*.bin,*.out,*.deb
set wildignore+=*/__pycache__/*
" Jump to the last position when reopening a file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Clear search-highlight when reloading vimrc.
noh
"}}}
" -- Appearance and Themes #themes ------------------------------------------{{{
" ---------------------------------------------------------------------------- "
" Enable truecolor.
set termguicolors
" Dark is power.
set background=dark
" Set colorscheme for vim.
colorscheme default
" -- Custom key bindings #keys ----------------------------------------------{{{
" ---------------------------------------------------------------------------- "
" set space as the map leader key
let mapleader="\<space>"
" space-space = clear search highlight
" nnoremap <leader><space> :let @/ = "deadbeef"<CR>:noh<CR>:echo ""<CR>
nnoremap <leader><space> :noh<CR>:echo ""<CR>
" Better shortcuts for pg-up and pg-down.
nnoremap K <c-u>zz
nnoremap J <c-d>zz
" symmetric shortcut for redo (undo-undo)
" nnoremap U <c-r>
" Shortcuts for copy-pasting from system clipboard (in visual mode).
vnoremap <leader>y "*y
vnoremap <leader>p "*p
" --- window management
" Add leader-w prefix for all window commands.
nnoremap <leader>w <c-w>
" maximize current window
nnoremap <leader>wm <c-w>o
" alias for close window.
nnoremap <leader>q <c-w>c
" -- buffer management
" next buffer
nnoremap <leader>bn :bn<cr>
" prev buffer
nnoremap <leader>bp :bp<cr>
" list buffers
nnoremap <leader>bb :Buffers<cr>
" delete current buffer
nnoremap <leader>bd :bd<cr>
nnoremap <leader>bdf :bd!<cr>
" better fold-toggle
nnoremap <leader>; zazz0
" prevent entering Ex mode accidentally
nnoremap Q <Nop>
" Tab/Shift-Tab to indent/un-indent in visual mode.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Keep selections when indenting.
vnoremap > >gv
vnoremap < <gv
" Reindent file.
" TODO: Does not work as expected.
nnoremap <leader>= magg=G`a:echo "File re-indented."<CR>
" -- Misc -------------------------------------------------------------------
" Set cursor on mode change.
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" reset the cursor on start:
augroup myCmds
au!
autocmd VimEnter * silent !echo -ne "\e[2 q"
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment