vimrc.md (1464B)
1 :vim: 2 3 # sudo command for when you forget 4 I often forget to open files in sudo when it's needed, 5 and don't notice until I've done a bunch of work 6 that I would prefer not to lose. 7 This is a great couple of lines to add, from 8 [Stack Overflow](https://stackoverflow.com/questions/2600783) 9 10 cmap w!! w !sudo tee > /dev/null % 11 12 This teaches a few things, as outlined on the SO post: 13 % means "current file" 14 When you call :w in Vim, it actually isn't modifying your file, 15 it is rather sending the current buffer to a file with the name you specify, 16 which is the current file if you pass no extra commands to :w, but could be anything 17 (e.g. :w biji2.mom). 18 In this case, we send it to `tee`, which sends to the specified file 19 (`%`) as well as the standard output, 20 which we redirect to `/dev/null` so it doesn't clutter up the stdout. 21 Vim is often not sudo-accessible, but tee is, so we bypass the problem I usually have. 22 23 # SpellBad and friends 24 25 Useful commands: 26 - leader + o to turn on spellcheck (Luke Smith's binding, nice). 27 - ]s to go to the next misspelled word, [s to go to the previous. 28 - zg to add a word to the internal dictionary. 29 30 Add the following into your .vimrc to get more sane orthographic highlighting: 31 32 hi clear SpellBad 33 hi clear SpellLocal 34 hi clear SpellCap 35 hi clear SpellRare 36 hi SpellBad ctermfg=red 37 hi SpellLocal ctermfg=green 38 hi SpellCap ctermfg=yellow 39 hi SpellRare ctermfg=green 40 41 42 Sun 17 Nov 2019 10:23:05 AM CST