Skip to content

Instantly share code, notes, and snippets.

@ZogStriP
Last active October 30, 2019 09:44
Show Gist options
  • Save ZogStriP/5e3a2a33aa584f98ebbf653018450f5c to your computer and use it in GitHub Desktop.
Save ZogStriP/5e3a2a33aa584f98ebbf653018450f5c to your computer and use it in GitHub Desktop.
" tabs & spaces
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
" search
set ignorecase " case insensitive
set smartcase " use case if any caps used
set incsearch " show match as search proceeds
set hlsearch " search highlighting
" change leader to ,
let mapleader = ","
" show line numbers
set number
" highlight current line
set cursorline
" highlight trailing whitespaces
match Todo /\s\+$/
" automatically remove trailing whitespaces on save
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" fzy fuzzy searching
function! FzyCommand(choice_command, vim_command)
try
let output = system(a:choice_command . " | fzy ")
catch /Vim:Interrupt/
" Swallow errors from ^C, allow redraw! below
endtry
redraw!
if v:shell_error == 0 && !empty(output)
exec a:vim_command . ' ' . output
endif
endfunction
nnoremap <leader>e :call FzyCommand("ag . --silent -l -g ''", ":e")<cr>
nnoremap <leader>v :call FzyCommand("ag . --silent -l -g ''", ":vs")<cr>
nnoremap <leader>s :call FzyCommand("ag . --silent -l -g ''", ":sp")<cr>
autocmd BufNewFile,BufRead *.js.es6 set syntax=javascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment