Skip to content

Instantly share code, notes, and snippets.

@Jesm
Last active October 19, 2023 20:04
Show Gist options
  • Save Jesm/71464bdb7b7c8aecb0bf2f93aee3a3e7 to your computer and use it in GitHub Desktop.
Save Jesm/71464bdb7b7c8aecb0bf2f93aee3a3e7 to your computer and use it in GitHub Desktop.
" References:
" https://dougblack.io/words/a-good-vimrc.html
" https://github.com/amix/vimrc
" Vundle setup
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'git@github.com:jwalton512/vim-blade.git'
Plugin 'git@github.com:posva/vim-vue.git'
Plugin 'scrooloose/nerdcommenter'
Plugin 'mileszs/ack.vim'
Plugin 'ctrlp.vim'
Plugin 'git@github.com:leafgarland/typescript-vim.git'
Plugin 'git@github.com:martinda/Jenkinsfile-vim-syntax.git'
Plugin 'git@github.com:sainnhe/sonokai.git'
Plugin 'git@github.com:mg979/vim-visual-multi.git'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Vim config
if has('termguicolors')
set termguicolors
endif
let g:sonokai_style='andromeda'
let g:sonokai_better_performance=1
set background=dark
colorscheme sonokai
syntax enable " enable syntax processing
set expandtab " tabs are spaces
set shiftwidth=4
set softtabstop=4 " number of spaces in tab when editing
set tabstop=4 " number of visual spaces per TAB
" set softtabstop=4 " number of spaces in tab when editing
set smarttab
set number " show line numbers in vim
set relativenumber " show relative line numbers
set wildmenu " visual autocomplete for command menu
" ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.ds_store,*/node_modules/*,*/vendor/*,*.d.ts
endif
set showmatch " highlight matching [{()}]
set incsearch " search as characters are entered
set hlsearch " highlight matches
set history=400 " numbers of lines to remember
set autoread " Autoload files changed from outside
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" :W sudo saves the file
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null
set so=7 " Give a line padding in the window when browsing a file
set ignorecase " Ignore case when searching
set wildignorecase " Ignore case when opening files
set smartcase " When searching try to be smart about cases
set lazyredraw " Don't redraw while executing macros (good performance config)
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Enable 256 colors palette in Gnome Terminal
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
set encoding=utf8 " Set utf8 as standard encoding
set ffs=unix,dos,mac " Use Unix as the standard file type
" Visualize tab
set list
set listchars=tab:!·,trail:·
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Sets the default VIM clipboard to be the system's clipboard
set clipboard=unnamedplus
set clipboard+=unnamed
" Move between tabs
nmap <Left> :tabprevious<cr>
nmap <Right> :tabnext<cr>
" Some shortcuts
nmap <leader>a :tabe<cr>:Ack
" Integrate with The Silver Searcher
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment