Muffinresearch Labs by Stuart Colville

vim: automatically highlight long lines | Comments (0)

Posted in Code, Linux/Unix on 22nd June 2009, 9:50 pm by Stuart

This .vimrc snippet highlights lines when you exceed 77 columns – this is especially useful if you are trying to adhere to PEP8 with Python development.

The if statement makes this work for older vims as well as more recent versions which is handy if you put your .vimrc on remote boxes as vim below v7.1.40 doesn’t have the matchadd function.

" Highlight lines over 77 columns
if has('matchadd')
    :au BufWinEnter * let w:m1=matchadd('Search', '\%<81v.\%>77v', -1)
    :au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
else
    :au BufRead,BufNewFile * syntax match Search /\%<81v.\%>77v/
    :au BufRead,BufNewFile * syntax match ErrorMsg /\%>80v.\+/
endif

To configure highlighting to work manually see the vim wiki for more details http://vim.wikia.com/wiki/Highlight_long_lines

Whilst I’ve often heard people snub the PEP8 recommendation for keeping line length to under 79 chars, I’ve personally found it leads to more readable code whether you live in a terminal or use gui editors. YMMV

Post Tools

Comments: Add yours







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Using Loggerhead with mod_wsgi|(0)

Here’s a post I wrote over on the Project Fondue Blog about our use of Loggerhead with mod_wsgi under Apache. Loggerhead is the rather nice branch viewer for bazaar branches as used on Launchpad.net.

If you’re not already subscribed to the Project Fondue blog feed then I can recommend it, as there should be some interesting posts coming out of there in the coming months (yes I’m unashamedly biased!).

Ubuntu: Turn off changing workspace with mouse wheel|(1)

I found the changing with the workspace with the mouse wheel really annoying. To disable it go to System => Preferences => CompizConfig (available if the compizconfig-settings-manager package is installed) and uncheck “Viewport Switcher” which is under the “Desktop” heading.

Photos on Flickr

© Copyright 2004-10 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.564s.