Skip to content

Instantly share code, notes, and snippets.

@Shubhayu-Das
Created October 1, 2021 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shubhayu-Das/5ec2511730e34af022812541f472b3a0 to your computer and use it in GitHub Desktop.
Save Shubhayu-Das/5ec2511730e34af022812541f472b3a0 to your computer and use it in GitHub Desktop.
My vim configuration file
" Navigation related stuff
nnoremap <S-Left> :tabprevious<CR>
nnoremap <S-Right> :tabnext<CR>
inoremap <S-Left> <ESC>:tabprevious<CR>
inoremap <S-Right> <ESC>:tabnext<CR>
" Shortcuts to make opening and closing vim easier
:nmap <C-q> :q<CR>
:imap <C-q> <ESC>:wq<CR>
:nmap <C-S-x> :q!<CR>
:imap <C-S-x> <ESC>:q!<CR>
:imap <C-s> <ESC>:w<CR>
:nmap <C-s> <ESC>:w<CR>
:imap <C-o> <ESC>:tabnew
:nmap <C-o> :tabnew
:nmap <C-_> i<ESC>\c<space><ESC>i
:imap <C-_> <ESC>\c<space><ESC>i
:vmap <C-_> <ESC>\c<space><ESC>
inoremap <C-/> :call NERDComment(0,"toggle")<CR>
vnoremap <C-/> :call NERDComment(0,"toggle")<CR>
" Split navigation tools
:nnoremap <C-h> <C-w>h
:nnoremap <C-l> <C-w>l
:nnoremap <C-k> <C-w>k
:imap <c-l> <ESC><c-l>i
" <C-p> is mapped to :CtrlP/n
" Toggle the netrw file explorer
:noremap <silent> <C-b> :call ToggleNetrw()<CR>
:inoremap <silent> <C-b> <ESC>:call ToggleNetrw()<CR>
" Terminal related commands
imap <silent> <C-j> <ESC>:vert term<CR>
nmap <silent> <C-j> :vert term<CR>
vmap <silent> <C-j> <ESC>:vert term<CR>
tnoremap <silent> <C-j> <C-\><C-n>:q!<CR>
" File related stuff
set path+=**
set wildmenu
set wildmode=list:longest,list:full
filetype plugin on
set encoding=utf-8
set nocompatible
set textwidth=120
set mouse=a
autocmd CursorHold,CursorHoldI * update
set mousefocus=on
set showmatch
set hlsearch
set smartcase
set incsearch
set ignorecase
set backspace=indent,eol,start
set ttyfast
set autoread
set autowrite
set splitright
set splitbelow
" Tab related things
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set autoindent
set smartindent
exec "set listchars=tab:\uBB\uBB,trail:.,nbsp:~"
set list
set title
set laststatus=2
set showtabline=2
set statusline^=[%n]\ %m\ %y\ %t\ %{strftime(\"%d-%m-%Y\")}\ %=\ L[%l/%L]\ C[%c]\ [%P]\ \ %{strftime(\"%H:%M:%S\")}\ \ \
set wildmenu
set hidden
set nu
set relativenumber
set noswapfile
set showmode
set showcmd
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,.git
colorscheme jellybeans
set lazyredraw
syntax on
:set cursorline
:set cursorcolumn
" Folding related stuff
set foldenable
set foldlevelstart=0
set foldnestmax=6
set foldmethod=indent
set termguicolors
set spell
set wrap
set linebreak
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" Set up persistent undo across all files.
set undofile
set undodir="~/.vim/undodir"
augroup highlights
autocmd Filetype .vimrc setlocal syntax off
augroup END
" Extention package manager
execute pathogen#infect()
" netrw window(inbuilt extension)
let g:netrw_banner=0
let g:netrw_winsize = -28
let g:netrw_liststyle = 3
let g:netrw_altv = 1
let g:netrw_sort_sequence = '[\/]$,*'
let g:netrw_browse_split = 4
let g:NetrwIsOpen=0
let g:netrw_keepdir=0
let g:netrw_sort_options = "i"
let g:netrw_list_hide= 'node_modules, __pycache__,.git'
" Function to toggle the explorer
function! ToggleNetrw()
if g:NetrwIsOpen
let i = bufnr("$")
while (i >= 1)
if (getbufvar(i, "&filetype") == "netrw")
silent exe "bwipeout " . i
endif
let i-=1
endwhile
let g:NetrwIsOpen=0
else
let g:NetrwIsOpen=1
silent Lexplore
endif
endfunction
" Toggle copy mode along with line numbering
fun! s:ToggleMouse()
if !exists("s:old_mouse")
let s:old_mouse = "a"
endif
if &mouse == ""
let &mouse = s:old_mouse
set nu
set relativenumber
echo "Mouse is for Vim (" . &mouse . ")"
else
let s:old_mouse = &mouse
set norelativenumber
set nonu
let &mouse=""
echo "Mouse is for terminal"
endif
endfunction
" NerdCommentor related settings
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
" let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment