From 14c46b12ae50db2b514e71edd1453526ca89b2ea Mon Sep 17 00:00:00 2001 From: Max Bucknell Date: Wed, 1 Feb 2017 23:57:13 +0000 Subject: [PATCH] Make vim happier in general. --- vim/vim.symlink/colors/maxbucknell.vim | 4 +++ vim/vimrc.symlink | 42 ++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/vim/vim.symlink/colors/maxbucknell.vim b/vim/vim.symlink/colors/maxbucknell.vim index 7bf4d94..9995c91 100644 --- a/vim/vim.symlink/colors/maxbucknell.vim +++ b/vim/vim.symlink/colors/maxbucknell.vim @@ -85,6 +85,10 @@ hi jsDocParam cterm=NONE ctermfg=2 ctermbg=NONE hi jsDocTypeNoParam cterm=NONE ctermfg=2 ctermbg=NONE hi jsDocSeeTag cterm=NONE ctermfg=2 ctermbg=NONE +" PHPDoc comments are comments. +hi phpDocTags cterm=NONE ctermfg=2 ctermbg=NONE +hi phpDocCustomTags cterm=NONE ctermfg=2 ctermbg=NONE + " Line numbers are grey hi LineNr cterm=NONE ctermfg=7 ctermbg=NONE diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink index b3beaad..655d538 100644 --- a/vim/vimrc.symlink +++ b/vim/vimrc.symlink @@ -66,9 +66,23 @@ set shell=bash " I want to use this to manage my ascii drawings set virtualedit=block +" Swap block and visual block +nnoremap v +nnoremap v + +vnoremap v +vnoremap v + +" Automatically read on update +set autoread + " I am always adding /g. No longer, suckers! set gdefault +" Set comment line length +set tw=72 +set fo=c + " Navigate to test, and back " Find test counterpart. @@ -375,15 +389,37 @@ augroup vimrcEx " This will automatically insert a new line in insert mode when a " line gets too long (above 80 characters). I can also run gqap " in normal mode to reflow a paragraph. - " - " I would like to have a customised version of this work with - " comments in code, but I haven't gotten that far yet. autocmd FileType \ markdown, \ setl tw=80 fo=t1 augroup END +" Make directories in a filename if they don't exist. + +function! AskQuit (msg, options, quit_option) + if confirm(a:msg, a:options) == a:quit_option + exit + endif +endfunction + +function! EnsureDirExists () + let required_dir = expand("%:h") + if !isdirectory(required_dir) + try + call mkdir( required_dir, 'p' ) + catch + echom "Could not create directory" + exit + endtry + endif +endfunction + +augroup AutoMkdir + autocmd! + autocmd BufNewFile * :call EnsureDirExists() +augroup END + " Set the statusline. " This shows something like: "