bartman's blog

C style

bartman

A new comer to my place of work was asking me how he can improve his code style. Here are some suggestions I had for him.

vim can do some of this for you. In particular it can warn that a line is too long.

    set textwidth=78          " Set the line wrap length
    match Error80 /\%>80v.\+/ " highlight anything past 80 in red

    if has("gui_running")
        hi Error80   gui=NONE   guifg=#ffffff   guibg=#6e2e2e
    else
        exec "hi Error80   cterm=NONE   ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(32)
    endif

See my vimrc, c.vim, and my_inkpot.vim (my colour scheme).

Tags: