Last active
November 1, 2019 10:32
-
-
Save Sebbestune/40b7392a726e5fda037a0accf34e7303 to your computer and use it in GitHub Desktop.
Vimrc trying to achieve maximum productivity (no specific rules)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" This vimrc comes from trying to get the highest workflow possible. I will | |
" try to combine all that I've learned. I'll not try to be minimal or maximal. | |
" I'll use some plugins I find useful but try to limit it to those plugins | |
" that don't give to hard of a performance hit and that increase my | |
" productivity. | |
"- Sebastian Lindgren 2019-11-01 | |
set nocompatible "Makes this vim not compatible with vi, allowing extra functionality to happen | |
filetype plugin on | |
"Used to enable syntax highlighting | |
syntax enable | |
" Let Vim load indentation rules (type found in: /usr/share/vim/vim??/ftplugin ) | |
if has("autocmd") | |
filetype plugin indent on | |
endif | |
source ~/.vim/config/vimset.vim | |
source ~/.vim/config/netrwconf.vim | |
"Also check file /.vim/config/powerfulcomments.vim | |
"Install Plug | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
"Also install ripgrep: | |
"curl -LO https://github.com/BurntSushi/ripgrep/releases/download/11.0.2/ripgrep_11.0.2_amd64.deb | |
"sudo dpkg -i ripgrep_11.0.2_amd64.deb | |
call plug#begin('~/.vim/plugged') "I also need to read some of these docs of use | |
Plug 'godlygeek/tabular' ":Tab /<expr> to make tabular fields look good (just found this too good to get rid off) | |
Plug 'tpope/vim-fugitive' "Interested in side by side view and additional statusbar stuff | |
Plug 'jiangmiao/auto-pairs' "Always gives auto pairs | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' "Very good search (especially with ripgrep) | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' "Just trying, this seems very good for productivity | |
Plug 'dense-analysis/ale' "Ale linting while writing | |
Plug 'liuchengxu/eleline.vim' "Statusline with ale support | |
call plug#end() | |
"------Ale config-------------------------- | |
" Fix files with prettier, and then ESLint. | |
let b:ale_fixers = ['prettier', 'eslint'] | |
" Equivalent to the above. | |
let b:ale_fixers = {'javascript': ['prettier', 'eslint']} | |
"For some extra convenience, I've found them to be easier to type/reach on my Swedish keyboard. | |
nnoremap B ^ | |
nnoremap E $ | |
"F1 reserved for help | |
nnoremap <F2> :GDiff :0 | |
nnoremap <F3> :Files<Cr> | |
nnoremap <F4> :Rg<Cr> | |
"Just because it's nice to have easy access to this | |
nnoremap <F10> :e $MYVIMRC<CR> | |
"Interesting function to highlight the cursor | |
nnoremap <C-K> :call HighlightNearCursor()<CR> | |
function HighlightNearCursor() | |
if !exists("s:highlightcursor") | |
match Todo /\k*\%#\k*/ | |
let s:highlightcursor=1 | |
else | |
match None | |
unlet s:highlightcursor | |
endif | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Make my netrw behave a little nicer | |
let g:netrw_liststyle = 3 | |
let g:netrw_sort_sequence = '[\/]$,*' | |
let g:netrw_browse_split = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"----------INSTEAD OF TCOMMENT PLUGIN----------------------------------------- | |
" To comment out blocks in vim: | |
" press Esc (to leave editing or other mode) | |
" hit ctrl+v (visual block mode) | |
" use the up/down arrow keys to select lines you want (it won't highlight everything - it's OK!) | |
" Shift+i (capital I) | |
" insert the text you want, i.e. % | |
" press EscEsc | |
" ----- | |
" To uncomment blocks in vim: | |
" press Esc (to leave editing or other mode) | |
" hit ctrl+v (visual block mode) | |
" use the ↑/↓ arrow keys to select the lines to uncomment. | |
" If you want to select multiple characters, use one or combine these methods: | |
" use the left/right arrow keys to select more text | |
" to select chunks of text use shift + ←/→ arrow key | |
" you can repeatedly push the delete keys below, like a regular delete button | |
" press d or x to delete characters, repeatedly if necessary | |
"------------------------------------------------------------------------------ | |
"----------MACRO RECORDING---------- | |
"(Why did I save this? Because it's so useful!) | |
" To start: q<letter><commands>q | |
" To execture: <number>@<letter> | |
"----BUILT-IN WORDCOMPLETION------------- | |
"Don't forget that ctrl-n gives word suggestions in instert mode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set showcmd " Show (partial) command in status line. | |
set showmatch " Show matching brackets. | |
set ignorecase " Do case insensitive matching | |
set smartcase " Do smart case matching | |
set incsearch " Incremental search | |
set autowrite " Automatically save before commands like :next and :make | |
set hidden " Hide buffers when they are abandoned | |
set mouse=a " Enable mouse usage (all modes) | |
set number " Shows a number on the side | |
set hlsearch " Highlight search pattern matches | |
set laststatus=2 " Always show the statusline | |
" set backupdir=~/.vim/backup// " This allows me to save backup to another location | |
" set directory=~/.vim/swap// " This allows me to save swapfiles to another location | |
" set undodir=~/.vim/undo/ " This allows me to save undo to another location/ | |
set autoread " Automatically read file again if changed outside vim | |
set viminfo='50,<100,s20,h " To be able to save larger amount of code with a yy | |
set backspace=indent,eol,start " Allow backspacing over everything in INSERT mode | |
set ruler " Show ruler and command visual aid | |
set showcmd " Show ruler and command visual aid | |
set noerrorbells " Disable bells | |
set visualbell " Disable bells | |
set t_vb= " Disable bells | |
set list " Show line number and listchars | |
set nu " Show line number and listchars | |
" set cursorline " Highlight the cursor line | |
set splitright " Set default vertical split to right | |
set tabstop=4 " Set soft tabs | |
set shiftwidth=4 " Set soft tabs | |
set ai " Indent | |
set si " Indent | |
set listchars=eol:¬,tab:▸\ ,trail:· " Show invisibles | |
highlight NonText guifg=#4a4a59 | |
highlight SpecialKey guifg=#4a4a59 | |
colorscheme desert " Set the colorscheme | |
"If I fold (use :<startno>,<endno>fo) then this saves the state for next time) | |
autocmd BufWinLeave *.* mkview | |
autocmd BufWinEnter *.* silent loadview | |
" CTRL-U in INSERT mode deletes a lot. Use CTRL-G u to first break undo, | |
" so that you can undo CTRL-U after inserting a line break. | |
inoremap <C-U> <C-G>u<C-U> | |
" Don't use Ex mode, use Q for formatting | |
map Q gq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment