<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mntnoe.com &#187; c++</title>
	<atom:link href="http://mntnoe.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://mntnoe.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Sep 2011 07:19:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Vim C++ Indentation Hack</title>
		<link>http://mntnoe.com/2008/07/vim-c-indentation-hack/</link>
		<comments>http://mntnoe.com/2008/07/vim-c-indentation-hack/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 10:41:12 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=39</guid>
		<description><![CDATA[It is possible to customize the behavior of cindent in Vim by writing a wrapper function. All you need is to find out which indentifiers Vim uses for calculating the new indent, and then find an appropriate regular expression. Suppose we do not want to indent stuff in namespace declarations. I found out that it [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to customize the behavior of <em>cindent</em> in Vim by writing a wrapper function. All you need is to find out which indentifiers Vim uses for calculating the new indent, and then find an appropriate regular expression.</p>
<p>Suppose we do not want to indent stuff in <em>namespace</em> declarations. I found out that it is enough to adjust the indentation of the first definition (except for a special case when using inheritance (&#8220;<em>: public &#8230;</em>&#8220;), see the code):<span id="more-39"></span></p>
<pre>setlocal nolisp
setlocal noautoindent

setlocal indentexpr=GetCppIndent(v:lnum)

if exists("*GetCppIndent")
    finish
endif

function! GetCppIndent(lnum)
    let cindent = cindent(a:lnum)
    if a:lnum == 1 | return cindent | endif

    let pattern1 = 'namespaces+S+s*{s*%$'
    " pattern2 is used to match this case:
    " class c : public b
    "     { &lt;-- cursor
    let clspat = 'classs+S+s*:s*[^{]*'
    let pattern2 = 'namespaces+S+s*{s*'.clspat.'%$'

    let lines = join(getline(max([ a:lnum - 10, 1]) , a:lnum-1), ' ')

    if  lines =~ pattern1
        return indent(CppFindOccurence('namespace', a:lnum))
    elseif  lines =~ pattern2 &amp;&amp; getline(a:lnum) =~ '^s*{'
        return indent(CppFindOccurence('class', a:lnum))
    else
        return cindent
    endif
endfunction

function! CppFindOccurence(pattern, lnum)
    for line in range(a:lnum-1,a:lnum-10,-1)
        if getline(line) =~ a:pattern
            return line
        endif
    endfor
    return -1
endfunction</pre>
<p>Please note that this is a hack, and thus not perfect. For instance, it does not take comments or preprocessing directives into account, but that should be easy to implement if it is an issue for you&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2008/07/vim-c-indentation-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ Coding Style Guidelines</title>
		<link>http://mntnoe.com/2008/06/c-coding-style-guidelines/</link>
		<comments>http://mntnoe.com/2008/06/c-coding-style-guidelines/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 11:47:38 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[coding style]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=38</guid>
		<description><![CDATA[I just came along the Inkscape Coding Style Guidelines. While written for the Inkscape project, I think it gives some food for thought when talking about code readability. Nice balance between being strict and pragmatic too. Whether you like the style or not, it worthy a read&#8230;]]></description>
			<content:encoded><![CDATA[<p>I just came along the <a href="http://www.inkscape.org/doc/coding_style.php">Inkscape Coding Style Guidelines</a>. While written for the Inkscape project, I think it gives some food for thought when talking about code readability. Nice balance between being strict and pragmatic too. Whether you like the style or not, it worthy a read&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2008/06/c-coding-style-guidelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

