<?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>Maxim Kim: Blog &#187; vim</title>
	<atom:link href="http://habamax.ru/blog/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://habamax.ru/blog</link>
	<description></description>
	<lastBuildDate>Tue, 24 Aug 2010 18:53:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Vim&#8217;s zx</title>
		<link>http://habamax.ru/blog/2009/06/vims-zx/</link>
		<comments>http://habamax.ru/blog/2009/06/vims-zx/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 09:08:49 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/2009/06/vims-zx/</guid>
		<description><![CDATA[Открыл для себя zx&#160;&#8212; раскрывает текущий фолдинг (&#171;складка&#187;, чтоль по русски?), закрывает все остальные. То бишь при set foldlevel=1, когда раскрыты все классы и закрыты все их методы, я топчу zx, чтобы раскрытым оставался только нужный метод. Удобно.]]></description>
			<content:encoded><![CDATA[<p>Открыл для себя <code>zx</code>&nbsp;&mdash; раскрывает текущий фолдинг (&laquo;складка&raquo;, чтоль по русски?), закрывает все остальные.</p>
<p>То бишь при <code>set foldlevel=1</code>, когда раскрыты все классы и закрыты все их методы, я топчу <code>zx</code>, чтобы раскрытым оставался только нужный метод.</p>
<p><a href="http://habamax.ru/blog/wp-content/uploads/2009/06/vim-zx.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/06/vim-zx-300x203.png" alt="vim-zx" title="vim-zx" width="300" height="203" class="aligncenter size-medium wp-image-423" /></a></p>
<p>Удобно.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/06/vims-zx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python folding in Vim</title>
		<link>http://habamax.ru/blog/2009/05/python-folding-in-vim/</link>
		<comments>http://habamax.ru/blog/2009/05/python-folding-in-vim/#comments</comments>
		<pubDate>Fri, 22 May 2009 08:59:20 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=380</guid>
		<description><![CDATA[There are several ftplugins at www.vim.org that fold python code. I could have used one of them and be happy but the burden of my ex-prog-life leads me to my own wheel to be reinvented. Brief description Folds are created for: let g:python_fold_block = "all"&#160;&#8212; all python code blocks; let g:python_fold_block = "def"&#160;&#8212; defs and [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ftplugins at <a href="http://www.vim.org">www.vim.org</a> that fold python code. I could have used one of them and be happy but the burden of my ex-prog-life leads me to my own wheel to be reinvented.</p>
<h2>Brief description</h2>
<ul>
<li>Folds are created for: </li>
<ul>
<li><code>let g:python_fold_block = "all"</code>&nbsp;&mdash; all python code blocks;</li>
<li><code>let g:python_fold_block = "def"</code>&nbsp;&mdash; defs and classes. <strong>[DEFAULT]</strong></li>
</ul>
<li>The way empty lines are folded controlled by <code>g:python_fold_keep_empty_lines</code> variable:</li>
<ul>
<li><code>let g:python_fold_keep_empty_lines = "all"</code>&nbsp;&mdash; keep empty lines between code blocks; <strong>[DEFAULT]</strong></li>
<li><code>let g:python_fold_keep_empty_lines = "top"</code>&nbsp;&mdash; keep empty lines between top level code blocks;</li>
<li><code>let g:python_fold_keep_empty_lines = "top-one"</code>&nbsp;&mdash; keep one empty line between top level code blocks;</li>
<li><code>let g:python_fold_keep_empty_lines = "one"</code>&nbsp;&mdash; keep one empty line between code blocks.</li>
</ul>
<li>Comment&#8217;s folding:</li>
<ul>
<li><code>let g:python_fold_comments = 1</code>&nbsp;&mdash; fold comments; <strong>[DEFAULT]</strong></li>
<li><code>let g:python_fold_comments = 0</code>&nbsp;&mdash; do not fold comments.</li>
</ul>
<li>Import&#8217;s folding:</li>
<ul>
<li><code>let g:python_fold_imports = 1</code>&nbsp;&mdash; fold imports; <strong>[DEFAULT]</strong></li>
<li><code>let g:python_fold_imports = 0</code>&nbsp;&mdash; do not fold imports.</li>
</ul>
<li>Docstring&#8217;s folding:</li>
<ul>
<li><code>let g:python_fold_docstrings = 1</code>&nbsp;&mdash; fold docstrings; <strong>[DEFAULT]</strong></li>
<li><code>let g:python_fold_docstrings = 0</code>&nbsp;&mdash; do not fold docstrings.</li>
</ul>
</ul>
<h2>Screenshots</h2>
<table>
<tr>
<td><a href="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_all.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_all-300x231.png" alt="p_fold_all" title="p_fold_all" width="300" height="231" class="aligncenter size-medium wp-image-384" /></a><br /><code>let g:python_fold_keep_empty_lines = "all"</code></td>
<td><a href="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_top.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_top-300x231.png" alt="p_fold_top" title="p_fold_top" width="300" height="231" class="aligncenter size-medium wp-image-385" /></a><br /><code>let g:python_fold_keep_empty_lines = "top"</code></td>
</tr>
<tr>
<td><a href="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_top-one.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_top-one-300x231.png" alt="p_fold_top-one" title="p_fold_top-one" width="300" height="231" class="aligncenter size-thumbnail wp-image-386" /></a><br /><code>let g:python_fold_keep_empty_lines = "top-one"</code></td>
<td><a href="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_one.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/05/p_fold_one-300x231.png" alt="p_fold_one" title="p_fold_one" width="300" height="231" class="aligncenter size-medium wp-image-402" /></a><br /><code>let g:python_fold_keep_empty_lines = "one"</code></td>
</tr>
</table>
<h2>Install</h2>
<ol>
<li><a href="http://habamax.ru/myvim/data/.vim/ftplugin/python.vim">Download <code>python.vim</code></a></li>
<li>Place <code>python.vim</code> to</li>
<ul>
<li>Windows: <code>~/vimfiles/ftplugin/</code></li>
<li>Linux: <code>~/.vim/ftplugin/</code></li>
</ul>
</ol>
<p>Note: Folding is <code>shiftwidth</code> dependent. If a code indented with 2 spaces make sure <code>shiftwidth</code> is 2 spaces too.</p>
<p>PS: It works for me and it may work for you too despite evil bugs that could live in it. <img src='http://habamax.ru/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/05/python-folding-in-vim/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>vimwiki 0.9.2, 0.9.2a, 0.9.2b</title>
		<link>http://habamax.ru/blog/2009/05/vimwiki-092-092a/</link>
		<comments>http://habamax.ru/blog/2009/05/vimwiki-092-092a/#comments</comments>
		<pubDate>Mon, 04 May 2009 08:17:44 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[vimwiki]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=362</guid>
		<description><![CDATA[This weekend new version of vimwiki was released. And right after it a small fix was done this monday&#160;&#8212; many thanks to (annoying) dos line endings. upd. .vba file still has dos CRLFs. The problem is in my new deployment script written in python. I will upload new .vba as soon as I am next [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend new version of vimwiki was released. And right after it a small fix was done this monday&nbsp;&mdash; many thanks to (annoying) dos line endings.</p>
<p><strong>upd</strong>. .vba file still has dos CRLFs. The problem is in my new deployment script written in python. I will upload new .vba as soon as I am next to my computer.<br />
<strong>upd2</strong>. Now there is vimwiki 0.9.2b with a couple of fixes and without dos lineendings.</p>
<p><strong>0.9.2b</strong></p>
<ul>
<li>FIX: Installation on Linux doesn&#8217;t work. (Dos line endings in Vimball archive file).</li>
<li>FIX: Clear out FlexWiki ftplugin&#8217;s setup. Now you don&#8217;t have to hack filetype.vim to get rid of unexpected &#8216;:setlocal bomb&#8217; from FlexWiki&#8217;s ftplugin.</li>
<li>FIX: When write done: it will show another done: in html file. </li>
</ul>
<p><strong>0.9.2a</strong></p>
<ul>
<li>FIX: Remove dos line endings from some files.</li>
</ul>
<p><strong>0.9.2</strong></p>
<ul>
<li>NEW: Option &#8216;folding&#8217; added to turn folding on/off.</li>
<li>NEW: Header text object. See :h vimwiki-text-objects.</li>
<li>NEW: Add/remove Header levels with &#8216;=&#8217; and &#8216;-&#8217;. See :h vimwiki_=.</li>
<li>NEW: Vimwiki GUI menu to select available wikies. See :h g:vimwiki_menu.</li>
<li>NEW: You can specify the name of your css file now. See :h vimwiki-option-css_name.</li>
<li>NEW: You can add styles to image links, see :h vimwiki-syntax-links.</li>
<li>FIX: History doesn&#8217;t work after :VimwikiRenameWord.</li>
<li>FIX: Some of wikipedia links are not correctly highlighted. Links with parentheses.</li>
<li>MISC: Renamed vimwiki_gtd to vimwiki_lst.</li>
</ul>
<p>Get it from <a href="http://code.google.com/p/vimwiki/downloads/list">vimwiki downloads list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/05/vimwiki-092-092a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vimwiki 0.9</title>
		<link>http://habamax.ru/blog/2009/03/vimwiki-09/</link>
		<comments>http://habamax.ru/blog/2009/03/vimwiki-09/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 06:30:45 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[vimwiki]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=347</guid>
		<description><![CDATA[What&#8217;s new: [new] You can add classes to &#8216;pre&#8217; tag&#160;&#8212; :h vimwiki-syntax-preformatted. This might be useful for coloring some programming code with external js tools like google syntax highlighter. [new] !WikiPage is not highlighted. It is just a plain word WikiPage in HTML. [new] Definition lists, see :h vimwiki-syntax-lists. [new] New implementation of :h VimwikiRenameWord. [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s new:</p>
<ul>
<li>[new] You can add classes to &#8216;pre&#8217; tag&nbsp;&mdash; <code>:h vimwiki-syntax-preformatted</code>. This might be useful for coloring some programming code with external js tools like google syntax highlighter.</li>
<li>[new] !WikiPage is not highlighted. It is just a plain word WikiPage in HTML.</li>
<li>[new] Definition lists, see <code>:h vimwiki-syntax-lists</code>.</li>
<li>[new] New implementation of <code>:h VimwikiRenameWord</code>. CAUTION: It was tested on 2 computers only, backup your wiki before use it. Email me if it doesn&#8217;t work for you.</li>
<li>[new] HTML: convert <code>[ ]</code> to html checkboxes.</li>
<li>[new] Default CSS: gray out checked items. </li>
<li>[fix] Less than 3 characters are not highlighted in Bold and Italic.</li>
<li>[fix] Added vimwiki autocmd group to avoid clashes with user defined autocmds.</li>
<li>[fix] Pressing ESC while <code>:VimwikiUISelect</code> opens current wiki index file.  Should cancel wiki selection.</li>
</ul>
<p>Get it from <a href="http://code.google.com/p/vimwiki/downloads/list">vimwiki downloads list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/03/vimwiki-09/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Run vimscript, run!</title>
		<link>http://habamax.ru/blog/2009/03/run-vimscript-run/</link>
		<comments>http://habamax.ru/blog/2009/03/run-vimscript-run/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 10:01:43 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[vimscript]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=332</guid>
		<description><![CDATA[:h :@ This is the command every Vim plugin developer should be aware of. I wish I knew about it earlier. " eval selected vimscript vmap &#60;Leader&#62;r "vy:@v&#60;CR&#62; " eval vimscript line nmap &#60;Leader&#62;r "vyy:@v&#60;CR&#62; Now with this screwdriver in my hands I can tinker at variables and functions of my plugin/script/colorscheme easily. That&#8217;s convenient. [...]]]></description>
			<content:encoded><![CDATA[<pre class="code">
:h :@
</pre>
<p>This is the command every Vim plugin developer should be aware of. I wish I knew about it earlier.</p>
<pre class="code">
" eval selected vimscript
vmap &lt;Leader&gt;r "vy:@v&lt;CR&gt;
" eval vimscript line
nmap &lt;Leader&gt;r "vyy:@v&lt;CR&gt;
</pre>
<p>Now with this screwdriver in my hands I can tinker at variables and functions of my plugin/script/colorscheme easily. That&#8217;s convenient. <img src='http://habamax.ru/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The only drawback is that it can&#8217;t eval vimscript&#8217;s longlines. Those with `\` in the beginning:</p>
<pre class="code">
" remove trailing spaces
map &lt;F4&gt; m`:silent! %s/\(\s\+$\)\\|\(\r$\)//g&lt;CR&gt;``
      \:echo "Remove trailing spaces and ^Ms ..."&lt;CR&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/03/run-vimscript-run/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vimwiki 0.8</title>
		<link>http://habamax.ru/blog/2009/03/vimwiki-08/</link>
		<comments>http://habamax.ru/blog/2009/03/vimwiki-08/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 20:09:09 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[vimwiki]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=321</guid>
		<description><![CDATA[At last! Vimwiki supports multiple wikies. If you upgrade from previous versions you should revisit all vimwiki&#8217;s options in your .vimrc. Most important &#8212; g:vimwiki_home has gone. Check :h vimwiki-options for additional information. Get Vimwiki 0.8 from its downloads list.]]></description>
			<content:encoded><![CDATA[<p>At last! Vimwiki supports multiple wikies.</p>
<p>If you upgrade from previous versions you should revisit all vimwiki&#8217;s options in your .vimrc. </p>
<p>Most important &#8212; g:vimwiki_home has gone. Check :h vimwiki-options for additional information.</p>
<p>Get Vimwiki 0.8 from its <a href="http://code.google.com/p/vimwiki/downloads/list">downloads list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/03/vimwiki-08/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LISP: Balance unmatched parentheses in Vim</title>
		<link>http://habamax.ru/blog/2009/02/lisp-balance-unmatched-parenthesis-in-vim/</link>
		<comments>http://habamax.ru/blog/2009/02/lisp-balance-unmatched-parenthesis-in-vim/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 11:58:13 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[vimscript]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=303</guid>
		<description><![CDATA[If you a vim guy hacking lisp or scheme the next vimscript could be useful for you. It closes unmatched parentheses on the current line, i.e.: (define (fact n) (if (= n 0) 1 (* n (fact (- n 1 ; cursor is on the line Pressing \) while on the last line will close [...]]]></description>
			<content:encoded><![CDATA[<p>If you a vim guy hacking lisp or scheme the next vimscript could be useful for you. It closes unmatched parentheses on the current line, i.e.:</p>
<pre class="code">
(define (fact n)
  (if (= n 0) 1
    (* n (fact (- n 1   ; cursor is on the line
</pre>
<p>Pressing <code>\)</code> while on the last line will close unbalanced parentheses on that line:</p>
<pre class="code">
(define (fact n)
  (if (= n 0) 1
    (* n (fact (- n 1)))))   ; cursor is on the line
</pre>
<p>Here is the vimscript, just put it into your .vimrc:</p>
<pre class="code">
function! s:rtrim(line) &quot;{{{
  return substitute(a:line, '\s*$', '', '')
endfunction &quot;}}}

function! s:find_rside_commentpos(lnum) &quot;{{{
  let line = getline(a:lnum)
  let col = stridx(line, ';')
  while col != -1 &amp;&amp;
        \ synIDattr(synID(a:lnum, col, 1), &quot;name&quot;) =~ &quot;String&quot;
    let col = stridx(line, ';', col + 1)
  endwhile
  return col
endfunction &quot;}}}

function! s:LISP_close_parens(lnum) &quot;{{{
  let save_cursor = getpos(&quot;.&quot;)

  call cursor(a:lnum, col('$'))
  let unbalanced = searchpair('(', '', ')', 'rmbcW',
        \ &quot;synIDattr(synID(line('.'), col('.'), 0), 'name') =~? &quot;.
        \ &quot;'\\(Comment\\|String\\)'&quot;)
  if unbalanced &gt; 0
    let line = getline(a:lnum)
    let unbalanced_str = repeat(')', unbalanced)
    let col = s:find_rside_commentpos(a:lnum)
    if col != -1
      let before_comment = strpart(line, 0, col)
      let wsp_cnt = strlen(before_comment) - strlen(s:rtrim(before_comment))
      let wsp_str = repeat(' ', wsp_cnt)
      let comment = strpart(line, col)
      call setline(a:lnum,
            \ s:rtrim(before_comment).unbalanced_str.wsp_str.comment)
    else
      let line = s:rtrim(line).unbalanced_str
      call setline(a:lnum, line)
    endif
  endif

  call setpos(&quot;.&quot;, save_cursor)
endfunction &quot;}}}

command! LISPCloseParens call &lt;SID&gt;LISP_close_parens(line('.'))
map &lt;Leader&gt;) :LISPCloseParens&lt;CR&gt;
map &lt;Leader&gt;( :LISPCloseParens&lt;CR&gt;
</pre>
<p>This is a way better version of my <a href="http://habamax.ru/blog/2008/08/vim-%D0%B7%D0%B0%D0%BA%D1%80%D1%8B%D1%82%D1%8C-%D0%BE%D1%82%D0%BA%D1%80%D1%8B%D1%82%D1%8B%D0%B5-%D1%81%D0%BA%D0%BE%D0%B1%D0%BA%D0%B8/">previous attempt (russian)</a> , which is to be frank just bad.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/02/lisp-balance-unmatched-parenthesis-in-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Vim, vimwiki and GTD</title>
		<link>http://habamax.ru/blog/2009/02/vim-vimwiki-and-gtd/</link>
		<comments>http://habamax.ru/blog/2009/02/vim-vimwiki-and-gtd/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 19:39:38 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[vim]]></category>
		<category><![CDATA[vimwiki]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=282</guid>
		<description><![CDATA[I have just implemented &#8220;toggleable list items&#8221;. Now you can make &#8220;projects&#8221; which are vimwiki&#8217;s lists of what you should do to make a project done. Project is done when all it&#8217;s elements are done == checked. Getting closer to emacs org-mode&#8230; PS. I wish i have implemented multiple wikies first.]]></description>
			<content:encoded><![CDATA[<p><a href="http://habamax.ru/blog/wp-content/uploads/2009/02/vimwiki-gtd.png"><img src="http://habamax.ru/blog/wp-content/uploads/2009/02/vimwiki-gtd-300x217.png" alt="vimwiki-gtd" title="vimwiki-gtd" width="300" height="217" class="alignleft size-medium wp-image-286" /></a>I have just implemented &#8220;toggleable list items&#8221;. Now you can make &#8220;projects&#8221; which are vimwiki&#8217;s lists of what you should do to make a project done. Project is done when all it&#8217;s elements are done == checked.<br />
Getting closer to emacs org-mode&#8230; <img src='http://habamax.ru/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS.<br />
I wish i have implemented multiple wikies first.</p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/02/vim-vimwiki-and-gtd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Indenting Python with Vim 2</title>
		<link>http://habamax.ru/blog/2009/02/indenting-python-with-vim-2/</link>
		<comments>http://habamax.ru/blog/2009/02/indenting-python-with-vim-2/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 19:23:26 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=250</guid>
		<description><![CDATA[Not that long time ago I began exploring Python. As a Vim adept I write almost all my code using it. And I was really disappointed with the way vim72 indents python&#8217;s code. Consider the following snippet that is indented by built in indent/python.vim script: for file in files: mkdir_copy(os.path.join(root, file), divider, os.path.join(BACKUP_DIR, dest_subdir)) The [...]]]></description>
			<content:encoded><![CDATA[<p>Not that long time ago I began exploring Python. As a Vim adept I write almost all my code using it. And I was really disappointed with the way vim72 indents python&#8217;s code. Consider the following snippet that is indented by built in <code>indent/python.vim</code> script:</p>
<pre class="brush: python;">
for file in files:
    mkdir_copy(os.path.join(root, file), divider,
        os.path.join(BACKUP_DIR, dest_subdir))
</pre>
<p>The code layout should look like (according to <a href="http://www.python.org/dev/peps/pep-0008/">PEP-8</a>):</p>
<pre class="brush: python;">
for file in files:
    mkdir_copy(os.path.join(root, file), divider,
               os.path.join(BACKUP_DIR, dest_subdir))
</pre>
<p>I googled up <a href="http://henry.precheur.org/2008/4/18/Indenting_Python_with_VIM.html">Indenting Python with VIM</a>&nbsp;&mdash; it suggests to use <a href="http://www.vim.org/scripts/script.php?script_id=974">Eric Mc Sween&#8217;s</a> script to solve most of indenting &#8220;problems&#8221;.  It is really nice&#8230; until you have a colon in a docstring or comment. And if you have it&nbsp;&mdash; <code>gg=G</code> will mess your python code right after it:</p>
<pre class="brush: python;">
# TODO:
    # this is an example of bad indenting
    if this_is_an_issue:
        print(&quot;Issue message&quot;)
</pre>
<p>This is definitly not what you want. Although it could be fixed quite easily (and actually I have fixed it) I think builtin script is more robust, so&#8230;<br />
I have fixed builtin <code>indent/python.vim</code> script too. Now it makes &#8220;sexy&#8221; braces indenting just like it should.<br />
But!<br />
Lack of &#8220;sexy&#8221; braces indenting in vim is not a big problem at all. Both &#8212; standard and suggested scripts &#8212; have indent error:</p>
<pre class="brush: python;">
if fullscreen:
    self.win_main = pyglet.window.Window(fullscreen=True, visible=False)
else:
    self.win_main = pyglet.window.Window(width=config.width,
            height=config.height,
            visible=False,
            vsync=True)

self.win_main.set_caption(&quot;Belveder %s&quot; % config.version)
</pre>
<p>Press <code>gg=G</code> :</p>
<pre class="brush: python;">
if fullscreen:
    self.win_main = pyglet.window.Window(fullscreen=True, visible=False)
else:
    self.win_main = pyglet.window.Window(width=config.width,
            height=config.height,
            visible=False,
            vsync=True)

    self.win_main.set_caption(&quot;Belveder %s&quot; % config.version)
</pre>
<p>The last line is indented. Code is broken!</p>
<p>I tried to address all mentioned issues in the fixed <a href="http://habamax.ru/myvim/data/.vim/indent/python.vim">indent/python.vim</a>.<br />
Use it with caution! <img src='http://habamax.ru/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/02/indenting-python-with-vim-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Маленький баг в indent/python.vim</title>
		<link>http://habamax.ru/blog/2009/02/%d0%bc%d0%b0%d0%bb%d0%b5%d0%bd%d1%8c%d0%ba%d0%b8%d0%b9-%d0%b1%d0%b0%d0%b3-%d0%b2-indentpythonvim/</link>
		<comments>http://habamax.ru/blog/2009/02/%d0%bc%d0%b0%d0%bb%d0%b5%d0%bd%d1%8c%d0%ba%d0%b8%d0%b9-%d0%b1%d0%b0%d0%b3-%d0%b2-indentpythonvim/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 08:29:40 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=235</guid>
		<description><![CDATA[В vim, чтобы писать программы на питоне, для правильной расстановки отступов, советуют использовать следующий indent/python.vim (ver 0.3). Потому как, встроенный в редактор не соответстует PEP 8. Однако есть там маленькая ошибка. Вот такой вот код: # TODO: # this is an example if this_is_an_issue: print(&#34;Issue message&#34;) будет отформатирован следующим образом: # TODO: # this is [...]]]></description>
			<content:encoded><![CDATA[<p>В vim, чтобы писать программы на питоне, для правильной расстановки отступов, <a href="http://henry.precheur.org/2008/4/18/Indenting_Python_with_VIM.html">советуют использовать</a> следующий <a href="http://www.vim.org/scripts/script.php?script_id=974">indent/python.vim (ver 0.3)</a>. Потому как, встроенный в редактор не соответстует <a href="http://www.python.org/dev/peps/pep-0008/">PEP 8</a>.</p>
<p>Однако есть там маленькая ошибка. Вот такой вот код:</p>
<pre class="code">
# TODO:
# this is an example
if this_is_an_issue:
    print(&quot;Issue message&quot;)
</pre>
<p>будет отформатирован следующим образом:</p>
<pre class="code">
# TODO:
    # this is an example of bad indenting
    if this_is_an_issue:
        print(&quot;Issue message&quot;)
</pre>
<p>Что, как видно, не верно.</p>
<p>Скрипт я для себя поправил, вечером отошлю исправления Eric Mc Sween&#8217;у.</p>
<p><strong>Update.</strong><br />
Его email помер.<br />
Тогда покажу, где и что на что поправить. В его indent/python.vim строчку под номером 179:</p>
<pre class="code">
    if pline =~ ':\s*$'
</pre>
<p>поменять на:</p>
<pre class="code">
    if pline =~ '^[^#]\+:\s*$'
</pre>
<p><strong>Update 2.</strong><br />
В итоге, все равно пользуюсь стандартным файлом. <img src='http://habamax.ru/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Пришлось, правда, его немного допилить. Чтобы после скобок ставил правильный &laquo;сдвиг&raquo; на следующих строках. Про это написал уже в <a href="http://habamax.ru/blog/2009/02/indenting-python-with-vim-2/">Indenting Python with Vim 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/02/%d0%bc%d0%b0%d0%bb%d0%b5%d0%bd%d1%8c%d0%ba%d0%b8%d0%b9-%d0%b1%d0%b0%d0%b3-%d0%b2-indentpythonvim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
