Skip to content

Instantly share code, notes, and snippets.

@edmondscommerce
Created October 25, 2017 10:18
Show Gist options
  • Save edmondscommerce/832a8c563d3cdb88fdf48414a680045f to your computer and use it in GitHub Desktop.
Save edmondscommerce/832a8c563d3cdb88fdf48414a680045f to your computer and use it in GitHub Desktop.
Joseph's basic vimrc file
" =============== STANDARD VIMRC STUFF ================
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup fedora
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
filetype plugin on
if &term=="xterm"
set t_Co=8
set t_Sb=dm
set t_Sf=dm
endif
" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"
" =============== CUSTOM STUFF STARTS ================
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" ================ Colour Scheme =====================
"turn on syntax highlighting
syntax on
colo torte
" ================ General Config ====================
set number relativenumber "Line numbers are good
set backspace=indent,eol,start "Allow backspace in insert mode
set history=1000 "Store lots of :cmdline history
set showcmd "Show incomplete cmds down the bottom
set showmode "Show current mode down the bottom
set gcr=a:blinkon0 "Disable cursor blink
set visualbell "No sounds
set autoread "Reload files changed outside vim when you run an external command
set ruler "Show the cursor position at all time
"set cursorline "Adds a line under the cursor
set ignorecase "Set ignorecase on.
set showmatch "showmatch: Show the matching bracket for the last ')'?
"set ve=all "allow the cursor to go beyond the end of the line
set hidden "open a new buffer without saving the current one
" case insensitive tab completion, if enabled
if exists("&wildignorecase")
set wildignorecase
endif
" ================ Turn Off Swap Files ==============
" Only do this if you also use the Persistent Undo Below
set noswapfile
set nobackup
set nowb
" ================ Persistent Undo ==================
" Keep undo history across sessions, by storing in file.
" Only works all the time.
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
" ================ Indentation ======================
set autoindent
set smartindent
set smarttab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
filetype plugin on
filetype indent on
" Display tabs and trailing spaces visually
"if has("patch-7.4.710")
set list listchars=tab:\ \ ,trail:·
"endif
" ================ Folds ============================
set foldmethod=manual "Only fold when told to - see here http://vim.wikia.com/wiki/Folding
" ================ Completion =======================
set wildmode=list:longest
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
" ================ Scrolling ========================
set scrolloff=8 "Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
" =============== PHPStorm ==========================
" This will open the current file in PHPStorm when you press <Ctrl>F
" You will need this plugin installed https://plugins.jetbrains.com/plugin/6027-remote-call
nmap <silent> <C-F> :!curl localhost:8091?message=%:p<CR><CR>
" ============== Windows ============================
"Use <Ctrl> J,K,L,H to move around split windows
nnoremap <C-J> <C-W>J<CR>
nnoremap <C-K> <C-W>K<CR>
nnoremap <C-L> <C-W>L<CR>
nnoremap <C-H> <C-W>H<CR>
" ====== Use Alt-arrow to move around windows ======
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" ============= Misc ================================
" type cd in normal mode to switch the pwd to that of the file
nmap <silent> cd :cd %:h<CR>
" ============= Markdown ============================
" For some reason vim doesn't recognise md files as markdown. Lets correct that
au BufNewFile,BufRead *.md call MarkdownFunction()
function MarkdownFunction()
set filetype=markdown
" And add syntax highlighting for code blocks
let g:markdown_fenced_languages = ['bash=sh', 'css', 'django', 'javascript', 'js=javascript', 'json=javascript', 'perl', 'php', 'python', 'ruby', 'sass', 'xml', 'html']
" Automatically spellcheck markdown
setlocal spell spelllang=en_gb
" highlight SpellBad ctermbg=NONE ctermfg=166 guibg=NONE guifg=#D3422E cterm=undercurl gui=undercurl guisp=#D3422E
" highlight SpellCap ctermbg=NONE ctermfg=68 guibg=NONE guifg=#3299CC cterm=undercurl gui=undercurl guisp=#3299CC
highlight SpellLocal ctermbg=NONE ctermfg=68 guibg=NONE guifg=#3299CC cterm=undercurl gui=undercurl guisp=#3299CC
" highlight SpellRare ctermbg=NONE ctermfg=109 guibg=NONE guifg=#8ABEB7 cterm=undercurl gui=undercurl guisp=#8ABEB7
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment