Skip to content

Instantly share code, notes, and snippets.

@deep5050
Last active January 20, 2025 16:35
Show Gist options
  • Select an option

  • Save deep5050/45d4cee2fe95b892ba8fffa7d40d75ad to your computer and use it in GitHub Desktop.

Select an option

Save deep5050/45d4cee2fe95b892ba8fffa7d40d75ad to your computer and use it in GitHub Desktop.
The ultimate vimrc you will ever need !!
" Set filetype to C for C files
autocmd BufNewFile,BufRead *.c,*.h,*.cpp,*.hpp set filetype=c
set encoding=utf-8
set fileencoding=utf-8
set fileformats=unix,dos,mac
set ruler
set hidden
set statusline=%F
set nolist
set number
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set nowrap
"set expandtab
set hlsearch
set incsearch
set wrap
set showmatch
set mouse=a
set undofile
set undodir=~/.vim/undodir
set completeopt=menuone,noselect
" Enable file type detection
filetype plugin indent on
" Enable syntax highlighting
syntax on
" Highlight trailing whitespace in red
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" Remove trailing whitespace on write
"autocmd BufWritePre * %s/\s\+$//e
" Map :Nowhite to remove traling whitespaces
command! Nowhite %s/\s\+$//e
" Automatically insert closing brackets and quotes
inoremap ( ()<Left>
inoremap [ []<Left>
inoremap { {}<Left>
inoremap " ""<Left>
inoremap ' ''<Left>
" Map F2 to perform diffget and go to the next diff
nnoremap <F2> :diffget<CR> :diffupdate<CR> :cnext<CR>
nnoremap <C-o> :Sex<CR>
" Keybinding to comment/uncomment lines
""nnoremap <C-c> :s/^/\/\/ /<CR>:noh<CR>
""nnoremap <C-u> :s/^\/\/ //<CR>:noh<CR>
" Keybinding to comment lines
nnoremap <C-c> :s/^\s*/&\/\/ /<CR>:noh<CR>
" Keybinding to uncomment lines
nnoremap <C-u> :s/^\(\s*\)\/\/ /\1/<CR>:noh<CR>
" Toggle line numbers with Ctrl-\
"nnoremap <c-\> :set number!<CR>
nnoremap \ :set number!<CR>
nnoremap , :set list!<CR>
nnoremap " :set mouse=a<CR>
nnoremap ' :set mouse=<CR>
" Keybinding to quickly save and quit
nnoremap <C-s> :w<CR>
nnoremap <C-q> :q<CR>
" Highlight the 80th character column
""highlight ColorColumn ctermbg=lightgrey
""set colorcolumn=80
" Display a vertical line at the 80th character column
""set textwidth=10
""set clipboard=unnamedplus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment