<?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>nonozone &#187; VIM</title>
	<atom:link href="http://www.nonozone.net/tag/vim/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nonozone.net</link>
	<description>冷眼旁观互联网</description>
	<lastBuildDate>Mon, 16 Jan 2012 10:11:42 +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中文乱码</title>
		<link>http://www.nonozone.net/solve-vim-chinese-garbled.html</link>
		<comments>http://www.nonozone.net/solve-vim-chinese-garbled.html#comments</comments>
		<pubDate>Wed, 09 Sep 2009 02:26:53 +0000</pubDate>
		<dc:creator>nonozone</dc:creator>
				<category><![CDATA[奇淫巧技]]></category>
		<category><![CDATA[VIM]]></category>
		<category><![CDATA[中文乱码]]></category>

		<guid isPermaLink="false">http://www.nonozone.net/solve-vim-chinese-garbled.html</guid>
		<description><![CDATA[有时候在使用vim的时候，显示中文为乱码，这个时候我们可以修改vimrc文件解决问题！ 首先，你需要搞清楚vimrc所在的位置。一般来说，在linux系统里，应该是这样 Linux: /usr/share/vim/vimrc 在Windows系统，应该是在vim的安装目录 Windows: c:\program files\vim\vimrc 我目前使用的是Windows7 ，路径显示为 C:\Program Files\Vim\_vimrc 这里所说的都是全局设定，打开vimrc文件后，只需要在文件最后添加以下代码就可以了： set fileencodings=utf-8,gb2312,gbk,gb18030 set termencoding=utf-8 set fileformats=unix set encoding=prc 这样，你的vim中文乱码问题就解决了！ 需要注意的是，在Windows7和vista下，由于加强版的管理员权限，你用vim直接打开vimrc文件，所做的修改是无法保存的！哪怕你使用的是:wq! 命令！一个简单的方法就是先在开始里面用管理员权限启动vim，然后通过vim打开vimrc文件做修改就可以了！<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="VIM中常用的替换模式总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VIM中常用的替换模式总结</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="六大拼音输入法双拼方案(码表)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fpinyin-input-method-shuangpin-six-programs-code-table.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26848672.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">六大拼音输入法双拼方案(码表)</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="不错的韩国MV《Nobody》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fgood-korea-mv-nobody.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26863899.jpg" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">不错的韩国MV《Nobody》</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Bluehost优惠码每月只要3.95美金" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fbluehost-promo-code-u-s-3-95-per-month-as-long-as.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bluehost优惠码每月只要3.95美金</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress防垃圾验证码插件Peter’s Custom Anti-Spam" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fwordpress-plugins-peter-s-custom-anti-spam.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress防垃圾验证码插件Peter’s Custom Anti-Spam</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>有时候在使用vim的时候，显示中文为乱码，这个时候我们可以修改vimrc文件解决问题！</p>
<p>首先，你需要搞清楚vimrc所在的位置。一般来说，在linux系统里，应该是这样</p>
<pre>Linux: /usr/share/vim/vimrc</pre>
<p>在Windows系统，应该是在vim的安装目录</p>
<pre>Windows: c:\program files\vim\vimrc</pre>
<p>我目前使用的是Windows7 ，路径显示为</p>
<p>C:\Program Files\Vim\_vimrc</p>
<p>这里所说的都是全局设定，打开vimrc文件后，只需要在文件最后添加以下代码就可以了：</p>
<blockquote>
<p>set fileencodings=utf-8,gb2312,gbk,gb18030<br />
    <br />set termencoding=utf-8</p>
<p>set fileformats=unix</p>
<p>set encoding=prc </p>
</blockquote>
<p>这样，你的vim中文乱码问题就解决了！</p>
<p>需要注意的是，在Windows7和vista下，由于加强版的管理员权限，你用vim直接打开vimrc文件，所做的修改是无法保存的！哪怕你使用的是:wq! 命令！一个简单的方法就是先在开始里面用管理员权限启动vim，然后通过vim打开vimrc文件做修改就可以了！</p>
<br /><g:plusone size="" href="http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html"></g:plusone><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="VIM中常用的替换模式总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VIM中常用的替换模式总结</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="六大拼音输入法双拼方案(码表)" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fpinyin-input-method-shuangpin-six-programs-code-table.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26848672.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">六大拼音输入法双拼方案(码表)</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="不错的韩国MV《Nobody》" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fgood-korea-mv-nobody.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26863899.jpg" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">不错的韩国MV《Nobody》</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Bluehost优惠码每月只要3.95美金" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fbluehost-promo-code-u-s-3-95-per-month-as-long-as.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bluehost优惠码每月只要3.95美金</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="WordPress防垃圾验证码插件Peter’s Custom Anti-Spam" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fwordpress-plugins-peter-s-custom-anti-spam.html&from=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">WordPress防垃圾验证码插件Peter’s Custom Anti-Spam</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.nonozone.net/solve-vim-chinese-garbled.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VIM中常用的替换模式总结</title>
		<link>http://www.nonozone.net/vim-model-commonly-used-in-the-replacement-summary.html</link>
		<comments>http://www.nonozone.net/vim-model-commonly-used-in-the-replacement-summary.html#comments</comments>
		<pubDate>Mon, 25 May 2009 06:57:08 +0000</pubDate>
		<dc:creator>nonozone</dc:creator>
				<category><![CDATA[奇淫巧技]]></category>
		<category><![CDATA[VIM]]></category>
		<category><![CDATA[查找替换]]></category>

		<guid isPermaLink="false">http://www.nonozone.net/vim-model-commonly-used-in-the-replacement-summary.html</guid>
		<description><![CDATA[最近在FTP的时候，都是用VIM作为我的默认文本编辑软件，这个软件我就不多介绍了，说他是最强大的文本编辑软件也不为过，当然就是因为太强大，所以刚开始使用的时候会觉得稍微有些无从下手，但是习惯以后，就好多了。 因为自己也时常会碰到一些问题无法解决，就把我碰到的一些问题，然后找出的答案放在这里，一是作为自己的一个笔记，而是跟大家分享一下。 今天跟大家分享的是在Vim中如何查找和替换，在记事本里直接用Ctrl+F就可以了，但是在VIM需要如下操作，我们这里用把four替换成4作为例子。 1，简单替换表达式 替换命令可以在全文中用一个单词替换另一个单词： :%s/four/4/g “%” 范围前缀表示在所有行中执行替换。最后的 “g” 标记表示替换行中的所有匹配点。如果仅仅对当前行进行操作，那么只要去掉%即可 &#160; 如果你有一个象 “thirtyfour” 这样的单词，上面的命令会出错。这种情况下，这个单词会被替换成”thirty4″。要解决这个问题，用 “\&#60;” 来指定匹配单词开头： &#160;&#160;&#160;&#160;&#160;&#160; :%s/\&#60;four/4/g 显然，这样在处理 “fourty” 的时候还是会出错。用 “\&#62;” 来解决这个问题： &#160;&#160;&#160;&#160;&#160;&#160; :%s/\&#60;four\&#62;/4/g 如果你在编码，你可能只想替换注释中的 “four”，而保留代码中的。由于这很难指定，可以在替换命令中加一个 “c” 标记，这样，Vim 会在每次替换前提示你： &#160;&#160;&#160;&#160;&#160;&#160; :%s/\&#60;four\&#62;/4/gc 2，删除多余的空格 要删除这些每行后面多余的空格，可以执行如下命令： &#160;&#160;&#160;&#160;&#160;&#160; :%s/\s\+$// 命令前面指明范围是 “%”，所以这会作用于整个文件。”substitute” 命令的匹配模式是 “\s\+$”。这表示行末（$）前的一个或者多个（\+）空格（\s）。替换命令的 “to” 部分是空的：”//”。这样就会删除那些匹配的空白字符。 3，匹配重复性模式 星号项 “*” 规定在它前面的项可以重复任意次。因此: &#160;&#160;&#160;&#160;&#160;&#160; /a* 匹配 “a”，”aa”，”aaa”，等等。但也匹配 “” (空字串)，因为零次也包含在内。星号 “*” 仅仅应用于那个紧邻在它前面的项。因此 “ab*” [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="解决VIM中文乱码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决VIM中文乱码</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="团购和限时购运营模式异同分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Foperational-mode-similarities-and-differences-of-group-buy-and-limited-buy.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">团购和限时购运营模式异同分析</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="国内微博客网站价值讨论" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fvalue-of-domestic-micro-blog-website-discussion.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">国内微博客网站价值讨论</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="团购网和LBS业务模式异同分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fcustomers-network-and-the-similarities-and-differences-of-lbs-business-models.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">团购网和LBS业务模式异同分析</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="苍井空老师实在是太太太好啦！" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Faoi-good-teacher-is-mrs-it.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26855010.jpg" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">苍井空老师实在是太太太好啦！</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>最近在FTP的时候，都是用VIM作为我的默认文本编辑软件，这个软件我就不多介绍了，说他是最强大的文本编辑软件也不为过，当然就是因为太强大，所以刚开始使用的时候会觉得稍微有些无从下手，但是习惯以后，就好多了。</p>
<p>因为自己也时常会碰到一些问题无法解决，就把我碰到的一些问题，然后找出的答案放在这里，一是作为自己的一个笔记，而是跟大家分享一下。</p>
<p>今天跟大家分享的是在Vim中如何查找和替换，在记事本里直接用Ctrl+F就可以了，但是在VIM需要如下操作，我们这里用把four替换成4作为例子。</p>
<p>1，简单替换表达式</p>
<p>替换命令可以在全文中用一个单词替换另一个单词：</p>
<p>:%s/four/4/g</p>
<p>“%” 范围前缀表示在所有行中执行替换。最后的 “g” 标记表示替换行中的所有匹配点。如果仅仅对当前行进行操作，那么只要去掉%即可</p>
<p>&#160; 如果你有一个象 “thirtyfour” 这样的单词，上面的命令会出错。这种情况下，这个单词会被替换成”thirty4″。要解决这个问题，用 “\&lt;” 来指定匹配单词开头：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; :%s/\&lt;four/4/g</p>
<p>显然，这样在处理 “fourty” 的时候还是会出错。用 “\&gt;” 来解决这个问题：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; :%s/\&lt;four\&gt;/4/g</p>
<p>如果你在编码，你可能只想替换注释中的 “four”，而保留代码中的。由于这很难指定，可以在替换命令中加一个 “c” 标记，这样，Vim 会在每次替换前提示你：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; :%s/\&lt;four\&gt;/4/gc</p>
<p>2，删除多余的空格</p>
<p>要删除这些每行后面多余的空格，可以执行如下命令：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; :%s/\s\+$//</p>
<p>命令前面指明范围是 “%”，所以这会作用于整个文件。”substitute” 命令的匹配模式是</p>
<p>“\s\+$”。这表示行末（$）前的一个或者多个（\+）空格（\s）。替换命令的 “to” 部分是空的：”//”。这样就会删除那些匹配的空白字符。</p>
<p>3，匹配重复性模式</p>
<p>星号项 “*” 规定在它前面的项可以重复任意次。因此:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /a*</p>
<p>匹配 “a”，”aa”，”aaa”，等等。但也匹配 “” (空字串)，因为零次也包含在内。星号 “*” 仅仅应用于那个紧邻在它前面的项。因此 “ab*” 匹配 “a”，”ab”，”abb”,”abbb”，等等。如要多次重复整个字符串，那么该字符串必须被组成一个项。组成一项的方法就是在它前面加 “\(”，后面加 “\)”。因此这个命令:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /\(ab\)*</p>
<p>匹配: “ab”，”abab”，”ababab”，等等。而且也匹配 “”。</p>
<p>要避免匹配空字串，使用 “\+”。这表示前面一项可以被匹配一次或多次。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /ab\+</p>
<p>匹配 “ab”，”abb”，”abbb”，等等。它不匹配 后面没有跟随 “b” 的 “a”。</p>
<p>要匹配一个可选项，用 “\=”。 例如:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /folders\=</p>
<p>匹配 “folder” 和 “folders”。</p>
<p>4，指定重复次数</p>
<p>要匹配某一项的特定次数重复，使用 “\{n,m}” 这样的形式。其中 “n” 和 “m” 都是数字。在它前面的那个项将被重复 “n” 到 “m” 次 (|inclusive| 包含 “n” 和 “m”)。例如:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /ab\{3,5}</p>
<p>匹配 “abbb”，”abbbb” 以及 “abbbbb”。</p>
<p>&#160; 当 “n” 省略时，被默认为零。当 “m” 省略时，被默认为无限大。当 “,m” 省略时，就表示重复正好 “n” 次。例如:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; 模式&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 匹配次数</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{,4}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0，1，2，3 或 4</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{3,}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3，4，5，等等</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{0,1}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0 或 1，同 \=</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{0,}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 0 或 更多，同 *</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{1,}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1 或 更多，同 \+</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; \{3}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3</p>
<p>5，多选一匹配</p>
<p>在一个查找模式中，”或” 运算符是 “\|”。例如:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /foo\|bar</p>
<p>这个命令匹配了 “foo” 或 “bar”。更多的抉择可以连在后面:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /one\|two\|three</p>
<p>匹配 “one”，”two” 或 “three”。</p>
<p>&#160; 如要匹配其多次重复，那么整个抉择结构须置于 “\(” 和 “\)” 之间:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /\(foo\|bar\)\+</p>
<p>这个命令匹配 “foo”，”foobar”，”foofoo”，”barfoobar”，等等。</p>
<p>&#160; 再举个例子:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; /end\(if\|while\|for\)</p>
<p>这个命令匹配 “endif”，”endwhile” 和 “endfor”。</p>
<p>源文档 &lt;<a href="http://wdicc.com/search-in-vim/">http://wdicc.com/search-in-vim/</a>&gt; </p>
<br /><g:plusone size="" href="http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html"></g:plusone><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="解决VIM中文乱码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fsolve-vim-chinese-garbled.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">解决VIM中文乱码</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="团购和限时购运营模式异同分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Foperational-mode-similarities-and-differences-of-group-buy-and-limited-buy.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">团购和限时购运营模式异同分析</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="国内微博客网站价值讨论" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fvalue-of-domestic-micro-blog-website-discussion.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">国内微博客网站价值讨论</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="团购网和LBS业务模式异同分析" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fcustomers-network-and-the-similarities-and-differences-of-lbs-business-models.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://www.nonozone.net/wp-content/uploads/2011/09/dll-file.png" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">团购网和LBS业务模式异同分析</font>
                    </a>
                </td>
                <td width="108" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="黑莓8310刷机图文教程（多图）" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.nonozone.net%2Fblackberry-8310-brush-graphic-guide-multi-map.html&from=http%3A%2F%2Fwww.nonozone.net%2Fvim-model-commonly-used-in-the-replacement-summary.html">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 102px !important; height: 102px !important;" src="http://static.wumii.com/site_images/2011/09/01/26855936.jpg" width="102px" height="102px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 108px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">黑莓8310刷机图文教程（多图）</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.nonozone.net/vim-model-commonly-used-in-the-replacement-summary.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

