Posts

Showing posts with the label vim

vim

`:bufdo e!` reload all tabs after `$ git pull`

W is not an editor option

command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args> command! -bang Q quit<bang> get rid of that annoying uppercase W complaint by pasting this into .bashrc

sort within blocks

Started using style guides, one of which specifies that CSS declarations be listed alphabetically. Not sure what most people’s solutions to that is, but I’m just going to whack CSS in however and periodically run vi{ :sort v - enter visual mode i{ - select inside braces : - enter command mode sort - sort alphabetically look at :help sort for other options, eg: %sort! - reverse alphabetical %sort u - sort and remove duplicate values %sort n - sort numeric etc

Statusline Arrows

I really want to use input mono as my main font for coding, but it seems to push out the alignment on my vim-airline and powerline-shell statuslines. Rather than get into a whole thing patching fonts with super-tweaked arrow icons I just decided I could live with square separators. Vim-Airline Add this to .vimrc : let g:airline_left_sep = '' let g:airline_right_sep = '' Add what you like between the quotes for separators. Powerline-shell Add --mode flat as a flag to the line that calls the python script in .bashrc . The other thing I did with powerline-shell was edit powerline-shell.py to the ‘untracked’ character is not u2753 , which is not available on any of the patched fonts. I used u26A0 which is a triangle with an exclaimation mark. Seems appropriate. I also finally figured out that the colors in powerline-shell/themes/default.py are the ones shown here - cterm or something, I dunno. Backup default.py change the colors as you...

vim clipboard

paste from system clipboard: "+p yank to system clipboard (without copying line numbers!): :1,21y+ (the above yanks lines 1 to 21 - use :%y+ to get everything ) There are probably logical extensions of these you can figure out.

vim find/replace

:8,20 s/search_term/replace_with/g :%s/foo/bar/gc - search whole doc, ask for confirmation

vim

From here: https://youtu.be/aHm36-na4-4?t=516   swap the colon and semi colon characters to minimise shift-pressing:   nnoremap ; :   nnoremap : ;     

default editor

export VISUAL=vim Sets vim as the default editor, I think. At least, when I run: crontab -e  to edit the cron jobs it now opens with vim instead of nano. more details at http://stackoverflow.com/questions/5952467/how-to-specify-a-editor-to-open-crontab-file-export-editor-vi-does-not-work I should figure out what that export command is really doing. sending an assignment of the editor name to a control file somewhere, I assume. Haven't successfully run a cronjob yet, though.

bash vi

set -o vi to set bash to vim-like controls. will need to add it to . bashrc to make it persistent. strangely difficult to locate this nugget! http://www.sluse.com/view/15121181