vim

I use the text editor “VIM” for almost everything, since it’s quick, does pretty much everything I need. It’s interface isn’t the quickest to learn, but once you can use it, it’s great.

I especially like being able to log into the server from any computer in the world and be able to have my whole environment available to me, I don’t have to install huge complex IDEs or whatever.

Some plugins I use:

and some bits I have in my .vimrc which may be interesting to you other VIMers:

	" Make line numbers fun.
	if (v:version >= 703)
		set rnu " relative line numbers
		highlight LineNr ctermbg=darkgrey ctermfg=black
		function! NumberToggle()
			if(&relativenumber == 1)
				set number
			elseif(&number == 1)
				set number!
			else
				set relativenumber
			endif
		endfunc
	else
		set number
		function! NumberToggle()
			set number!
		endfunc
	endif

and

	function! ColourPicker()
		" Save previous " register to restore at the end
		let [qr, qt] = [getreg('"'), getregtype('"')]
		" delete current word to " register
		normal Bde
		" colourpicker w/ current word, and put in " register
		call setreg('"', system(printf("colourpicker %s", shellescape(@"))))
		" paste it back in again.
		silent norm! P
		" and restore previously saved " register.
		call setreg('"', qr, qt)
	endfunction

	map <leader>c :call ColourPicker()<cr>

Spacebar leaderkey

One thing I only recently did was switch the spacebar to being my ‘leaderkey’. I’d not really used the ‘leader’ stuff much before, but now it’s all working I really like it.

	let mapleader="±"
	map <space> <leader>

which seems a bit odd, but seems to work. Essentially I’ve mapped the “real” leaderkey to something I can’t easily access by accident, and then (outside of visual / insert mode) mapped space to the leader. I was trying for a while to figure out some kind of noimap or something syntax to say only do this outside of visual/ insert mode, but then this works without any complexity. Cool.

I’ve then assigned a bunch of window/pane movement leaderkeys:

	map <leader><left> <c-w><left>
	map <leader><right> <c-w><right>
	map <leader><up> <c-w><up>
	map <leader><down> <c-w><down>

	map <leader>h <c-w><left>
	map <leader>l <c-w><right>
	map <leader>k <c-w><up>
	map <leader>j <c-w><down>

	map <leader>v <esc>:vspl<cr>
	map <leader>S <esc>:spl<cr>
	map <leader>q <esc>:q<cr>

	map <leader><space> <c-w><c-w>

which lets me switch windows with hitting space and then a direction, or swap windows with double tapping space.

Visible tabs and spaces:

A couple of minor things that really bug me is spaces at the end of lines, and mixing tabs and spaces. Here’s a couple of bits which make that a bit better.

	" spaces at end of line:
	au FileType * syntax match WhitespaceEOL /\s\+$/
	highlight WhitespaceEOL ctermbg=red guibg=red

	" Display tabs as "| " in a slightly grey color:
	au FileType * syntax match RealTab /\t/
	highlight RealTab ctermbg=black guibg=black

	set listchars=tab:\|\ 
	set list

Python PEP8 style helpers

It’s also pretty helpful having a visual reminder about line lengths:

	au FileType python set colorcolumn=81