Created
November 11, 2017 21:58
-
-
Save gammy/a85c995fa6579944f35bea494f640274 to your computer and use it in GitHub Desktop.
Gammies vimrc
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
" Gammies vimrc. This will work for both vim and gvim. | |
" Use Vim settings, rather then Vi settings | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
set nomodeline " Disable trying to read modelines in files | |
" (best to keep it off if you're unaware of it anyway) | |
" Automatically vsplit "foo.h" if "foo.c" is loaded and "foo.h" exists | |
function! OpenCFile() | |
let cfile = bufname("%") | |
let hfile = strpart(cfile, 0, strlen(cfile) - 2) . ".h" | |
if filereadable(hfile) | |
execute "botright vnew " . hfile | |
endif | |
endfunction | |
if has("autocmd") | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
" Inform vim that .pde and .ino are aduino files | |
autocmd! BufNewFile,BufRead *.pde setlocal filetype=arduino | |
autocmd! BufNewFile,BufRead *.ino setlocal filetype=arduino | |
endif | |
" Load bin-files via the xxd hexdump program. Don't ask me how this works. | |
augroup Binary au! | |
au BufReadPre *.bin let &bin=1 | |
au BufReadPost *.bin if &bin | %!xxd | |
au BufReadPost *.bin set filetype=xxd | endif | |
au BufWritePre *.bin if &bin | %!xxd -r | |
au BufWritePre *.bin endif | |
au BufWritePost *.bin if &bin | %!xxd | |
au BufWritePost *.bin set nomod | endif | |
augroup END | |
if has("viminfo") | |
" Specify what to store in the global viminfo file; commandline history | |
", search string history, etc (:help viminfo) | |
set viminfo='10,\"100,:20,%,n~/.viminfo | |
endif | |
set backup " keep a backup file | |
set history=500 | |
set incsearch " do incremental searching | |
set hlsearch " highlight (previous) search matches | |
set scrolloff=3 " Keep this number of lines above/below the cursor | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
""" Encoding conversion | |
" Convert non-utf8 files to utf8, and do so without marking the | |
" buffer as modified | |
set fileencoding=utf8 nomodified | |
""" Indentation | |
" See ":he cinoptions-values" if this seems confusing | |
set cinoptions={,:,+,t0,g,^,e,n,p,(0,= cindent | |
set nosmarttab | |
set expandtab " Substitute a <tab> keypress with | |
set tabstop=4 " .. number of spaces. | |
set shiftwidth=4 " .. do the same when autoindenting as you work | |
" Switch syntax highlighting on, when the terminal has colors | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
endif | |
" Inform vim that we're using a dark background color | |
" needs to be before highlights | |
set background=dark | |
if has("gui_running") | |
set cursorline " Highlight the line on which the cursor is on | |
set guifont=Ubuntu\ Mono\ Regular\ " Font to use in gvim | |
colorscheme moria " http://www.vim.org/scripts/script.php?script_id=1464 | |
" highlight ColorColumn guibg=#2f2020 " Must be set after the colorscheme | |
" Gutter background (visible when using it, e.g when using vim-signify) | |
else | |
colorscheme desert | |
"highlight normal ctermbg=black " Force black background | |
endif | |
" Highlights must be set after the colorscheme as they override them | |
" signcolumn (gutter): Dark red for console, dark blue/grey for moria(gvim) | |
highlight SignColumn ctermbg=darkred guibg=#293138 | |
" colorcolumn: Dark grey for console, dark red for moria(gvim) | |
highlight ColorColumn ctermbg=brown guibg=#2f2020 | |
set ruler " show the cursor position all the time | |
set colorcolumn=80 " Highlight the 80th column | |
set showcmd " display incomplete commands | |
""" Keybindings | |
" F2 / F3: Enter / leave paste+insert mode | |
map <F2> <Esc>:set paste<CR>i | |
map <F3> <Esc>:set nopaste<CR> | |
" -: Svennetangentbord: map - to / | |
"map - <Esc>/ | |
" F4: Try running the buffer-to-html plugin | |
map <F4> <ESC>:runtime! s""yntax/2html.vim<CR> | |
" Copy selection to clipboard with ^c (untested in vim actually) | |
map <C-c> "+y<CR> | |
" Paste clipboard with ^p | |
" (^v is Visual Block mode, so we don't want to override that!) | |
map <C-p> "+P<CR> | |
" As the above 80th column thing won't work when restoring vim sessions for | |
" some reason (bug?), here's a little helper macro to restore it: | |
command Fixcol highlight ColorColumn guibg=#2f2020 | |
""" Sessions | |
" Additional session options used with :mksession and -S, | |
" see `:help sessionoptions` | |
set sessionoptions+=resize,winpos,winsize,tabpages | |
""" Plugin options | |
if exists("g:loaded_signify") | |
" Vim-signify: https://github.com/mhinz/vim-signify | |
let g:signify_vcs_list = ['git'] " signify plugin variable; check for git | |
let g:airline_powerline_fonts = 1 " airline plugin thing | |
endif | |
" Vim-airline | |
"vim-airline doesn't appear until I create a new split; his seems to fix it? | |
set laststatus=2 | |
"let g:airline_theme='dark' | |
" Printer.. | |
set printdevice=Brother_HLL2340D | |
" The 'nested' keyword fixes parsing of modelines in the function, | |
" so that the rest of the vimrc is respected in the "foo.h" buffer | |
autocmd BufRead *.c nested call OpenCFile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment