Skip to content

Instantly share code, notes, and snippets.

@christophergorexyz
Last active April 3, 2025 02:52
Show Gist options
  • Select an option

  • Save christophergorexyz/9529187 to your computer and use it in GitHub Desktop.

Select an option

Save christophergorexyz/9529187 to your computer and use it in GitHub Desktop.
.vimrc
"auto complete using ALE, must be set before loading the plugin
let g:ale_completion_enabled=1
"load any plugins here
call plug#begin()
"linting with ALE
Plug 'dense-analysis/ale'
call plug#end()
"ALE config
let g:ale_fixers=['eslint_d']
let g:ale_fix_on_save=1
let $ESLINT_D_PPID = getpid()
let g:ale_javascript_eslint_executable = 'eslint_d'
let g:ale_javascript_eslint_use_global = 1
"auto completion with ALE
set omnifunc=ale#completion#OmniFunc
set nu "line nums
set ru "ruler
set ai "autoindent
set si "smartindent
set et "expandtab
set bs=2 "indent,eol,start
set ts=2 "tabstop
set sts=2 "softtabstop
set sw=2 "shiftwidth -- required for correct auto indentation
set background=dark "we use darkmode in this house
set mouse=a "enable the mouse
set wildmode=full
set wildmenu
set fileencoding=utf-8
set laststatus=2 "show the status bar always
"keep a minimum of 2 lines/cols of context around cursor
set scrolloff=2
set sidescrolloff=2
"search highlighting
set hlsearch
"clear search highlighting with <Space>
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
"octal numbers start only with 0, unlike hex (0x) and binary (0b), making the
"inclusion of octals here problematic for non-octal padded numbers
set nrformats-=octal
"show erroneous whitespace or potential steganographic whitespace
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set list
"automatically re-read the file if it's been written from outside of vim
set autoread
"remove comment leader on line join
set formatoptions+=j
"reindent
command Reindent :normal! gg=G
"a simple regex to remove trailing whitespace
command RemoveTrailingWhiteSpace %s/\s\+$//g
"removes windows characters from end of line
command RemoveWindowsMagic %s/\r$//g
"remove trailing whitespace and reindent
command FixWhiteSpace :execute "RemoveWindowsMagic" | :execute "RemoveTrailingWhiteSpace" | :execute "Reindent"
"replace tabs with spaces
command ReplaceTabsWithSpaces %s/\t/ /g
"a simple xml cleanup regex to add lines between tags and whitespace fix
command Tidyxml %s/></>\r</g | :execute "FixWhiteSpace"
"autocmd BufWritePre *.\(x\|ht\)ml Tidyxml
"autocmd BufWritePre * RemoveWindowsMagic
"autocmd BufWritePre * RemoveTrailingWhiteSpace
"autocmd BufWritePre * ReplaceTabsWithSpaces
"autocmd BufWritePre * Reindent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment