﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-hdqqq-随笔分类-其他开发语言</title><link>http://www.cppblog.com/hdqqq/category/6948.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 07 Dec 2010 14:18:14 GMT</lastBuildDate><pubDate>Tue, 07 Dec 2010 14:18:14 GMT</pubDate><ttl>60</ttl><item><title>VIM实现自动添加新行</title><link>http://www.cppblog.com/hdqqq/archive/2010/12/07/135719.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Tue, 07 Dec 2010 09:59:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2010/12/07/135719.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/135719.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2010/12/07/135719.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/135719.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/135719.html</trackback:ping><description><![CDATA[<div style="text-align: center;">VIM实现自动添加新行<br></div>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; emacs在编辑代码时，有个功能，在输入｛｝；时可以自动追加新的一行。减少敲回车的次数。将下面的代码加入VIM的配置文件后，可以在编辑c,cpp,h后缀的文件时，也同样有这个功能。<br><br><br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">function&nbsp;Find_for()<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;search(</span><span style="color: #000000;">'</span><span style="color: #000000;">^\s*[f]or</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">b</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;line(</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">'</span><span style="color: #000000;">))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">""</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;search(</span><span style="color: #000000;">'</span><span style="color: #000000;">\"</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">b</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;line(</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">'</span><span style="color: #000000;">))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;searchpair(</span><span style="color: #000000;">'</span><span style="color: #000000;">\"</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">''</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">\"</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">b</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">''</span><span style="color: #000000;">,&nbsp;line(</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">'</span><span style="color: #000000;">))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">\r</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">""</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;search(</span><span style="color: #000000;">'</span><span style="color: #000000;">\</span><span style="color: #000000;">'''</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">b</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;line(</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">'</span><span style="color: #000000;">))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;searchpair(</span><span style="color: #000000;">'</span><span style="color: #000000;">\</span><span style="color: #000000;">'''</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">;</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">\</span><span style="color: #000000;">'''</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">b</span><span style="color: #000000;">'</span><span style="color: #000000;">,&nbsp;</span><span style="color: #000000;">''</span><span style="color: #000000;">,&nbsp;&nbsp;line(</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">'</span><span style="color: #000000;">))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">\r</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">""</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">\r</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>endfunction<br>&nbsp;<br>autocmd&nbsp;BufReadPost&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.{c,cpp,h}&nbsp;inoremap&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">expr</span><span style="color: #000000;">&gt;&lt;</span><span style="color: #000000;">buffer</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">{</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;">\r</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>autocmd&nbsp;BufReadPost&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.{c,cpp,h}&nbsp;inoremap&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">expr</span><span style="color: #000000;">&gt;&lt;</span><span style="color: #000000;">buffer</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">}</span><span style="color: #000000;">'</span><span style="color: #000000;">.</span><span style="color: #000000;">"</span><span style="color: #000000;">\r</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>autocmd&nbsp;BufReadPost&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">.{c,cpp,h}&nbsp;inoremap&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">expr</span><span style="color: #000000;">&gt;&lt;</span><span style="color: #000000;">buffer</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;;&nbsp;&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">;</span><span style="color: #000000;">'</span><span style="color: #000000;">.Find_for()</span></div>
<br>&nbsp;&nbsp;&nbsp;&nbsp; 缺点，对于&#8220;和&#8216;的匹配没有重复，嵌套检测的功能。在某些情况下，会导致自动回车。<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; 如：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "hello world" &lt;&lt; "second ;<br>&nbsp;&nbsp;&nbsp;&nbsp; 有兴趣的话，可以再改进一下。<br><br> <img src ="http://www.cppblog.com/hdqqq/aggbug/135719.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2010-12-07 17:59 <a href="http://www.cppblog.com/hdqqq/archive/2010/12/07/135719.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个NERD_tree的改进</title><link>http://www.cppblog.com/hdqqq/archive/2010/09/25/127587.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Sat, 25 Sep 2010 02:49:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2010/09/25/127587.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/127587.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2010/09/25/127587.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/127587.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/127587.html</trackback:ping><description><![CDATA[NERD_tree是vim的一个插件，支持树形显示目录和文件，此插件支持文件和隐藏文件过滤，可以设置一个文件过滤的表达式列表,来阻止NERD_tree显示这些文件。<br><br>但是在有些情况下，想要显示某些特定后缀的文件，如一个h头文件和cpp代码文件混合的目录，想只显示cpp文件，NERD_tree的过滤就显得有些不方便，因为原来实现的是排除过滤。<br><br>因此，对NERD_tree做了些改进，可以过滤显示某种类型的文件。<br><br>使用方法：<br><br>将光标移动到某个文件：<br><br>l&nbsp;&nbsp; 只显示此类后缀的文件<br>L&nbsp;&nbsp; 恢复显示所有文件<br><br>安装方法：<br><br>filter.vim&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 复制到vim插件目录的nerdtree_plugin 目录下<br>NERD_tree.vim&nbsp;&nbsp; 替换原来的plugin目录下的文件<br><br>下载地址：<br><br>http://www.cppblog.com/Files/hdqqq/nerd_tree_improve.zip<br><br><br> <img src ="http://www.cppblog.com/hdqqq/aggbug/127587.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2010-09-25 10:49 <a href="http://www.cppblog.com/hdqqq/archive/2010/09/25/127587.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个轻量级家用爬虫</title><link>http://www.cppblog.com/hdqqq/archive/2008/05/09/49300.html</link><dc:creator>hdqqq</dc:creator><author>hdqqq</author><pubDate>Fri, 09 May 2008 06:09:00 GMT</pubDate><guid>http://www.cppblog.com/hdqqq/archive/2008/05/09/49300.html</guid><wfw:comment>http://www.cppblog.com/hdqqq/comments/49300.html</wfw:comment><comments>http://www.cppblog.com/hdqqq/archive/2008/05/09/49300.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.cppblog.com/hdqqq/comments/commentRss/49300.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hdqqq/services/trackbacks/49300.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一个简单的网络爬虫&nbsp;&nbsp;<a href='http://www.cppblog.com/hdqqq/archive/2008/05/09/49300.html'>阅读全文</a><img src ="http://www.cppblog.com/hdqqq/aggbug/49300.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hdqqq/" target="_blank">hdqqq</a> 2008-05-09 14:09 <a href="http://www.cppblog.com/hdqqq/archive/2008/05/09/49300.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>