﻿<?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++博客-小鸟学C++-文章分类-Linux学习笔记</title><link>http://www.cppblog.com/zjy17243/category/17197.html</link><description>基础学习</description><language>zh-cn</language><lastBuildDate>Wed, 05 Mar 2014 11:04:52 GMT</lastBuildDate><pubDate>Wed, 05 Mar 2014 11:04:52 GMT</pubDate><ttl>60</ttl><item><title>linux shell 正则表达式(BREs,EREs,PREs)差异比较（转载）</title><link>http://www.cppblog.com/zjy17243/articles/206049.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Wed, 05 Mar 2014 10:52:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/206049.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 我想各位也和我一样，再linux下使用grep，egrep, awk , sed, vi的搜索时，会经常搞不太清楚，哪此特殊字符得使用转义字符'\' .. &nbsp; 哪些不需要， grep与egrep的差异等等。下面就是我在网上找到的一篇介绍这方面的文章。如下：转载自：http://www.cnblogs.com/chengmo/archive/2010/10/10/1847287.html正...&nbsp;&nbsp;<a href='http://www.cppblog.com/zjy17243/articles/206049.html'>阅读全文</a><img src ="http://www.cppblog.com/zjy17243/aggbug/206049.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2014-03-05 18:52 <a href="http://www.cppblog.com/zjy17243/articles/206049.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vim编码问题(转载)</title><link>http://www.cppblog.com/zjy17243/articles/204973.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Mon, 23 Dec 2013 12:04:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/204973.html</guid><wfw:comment>http://www.cppblog.com/zjy17243/comments/204973.html</wfw:comment><comments>http://www.cppblog.com/zjy17243/articles/204973.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zjy17243/comments/commentRss/204973.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zjy17243/services/trackbacks/204973.html</trackback:ping><description><![CDATA[<p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">在 Vim 中，有四个与编码有关的选项，它们是：<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencodings</code>、<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>、<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;和&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>。在实际使用中，任何一个选项出现错误，都会导致出现乱码。因此，每一个 Vim 用户都应该明确这四个选项的含义。下面，我们详细介绍一下这四个选项的含义和作用。</p><h1>1&nbsp;encoding</h1><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;"><code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;是 Vim 内部使用的字符编码方式。当我们设置了&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;之后，Vim 内部所有的 buffer、寄存器、脚本中的字符串等，全都使用这个编码。Vim 在工作的时候，如果编码方式与它的内部编码不一致，它会先把编码转换成内部编码。如果工作用的编码中含有无法转换为内部编码的字符，在这些字符就会丢失。因此，在选择 Vim 的内部编码的时候，一定要使用一种表现能力足够强的编码，以免影响正常工作。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">由于&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;选项涉及到 Vim 中所有字符的内部表示，因此只能在 Vim 启动的时候设置一次。在 Vim 工作过程中修改<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;会造成非常多的问题。如果没有特别的理由，请始终将&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;设置为&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">utf-8</code>。为了避免在非 UTF-8 的系统如 Windows 下，菜单和系统提示出现乱码，可同时做这几项设置：</p><div style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #ffffff; border: 1px solid #808080; margin-left: 2em; margin-right: 2em; padding: 0.5em; font-size: 9pt; overflow: auto; line-height: normal;"><span style="font-weight: bold; color: #a52a2a;">set</span>&nbsp;<span style="color: #800080;">encoding</span>=utf-8<br /><span style="font-weight: bold; color: #a52a2a;">set</span>&nbsp;<span style="color: #800080;">langmenu</span>=zh_CN.UTF-8<br /><span style="font-weight: bold; color: #a52a2a;">language</span>&nbsp;message&nbsp;<span style="font-weight: bold; color: #a52a2a;">z</span>h_CN.UTF-<span style="color: #ff00ff;">8</span></div><h1>2&nbsp;termencoding</h1><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;"><code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;是 Vim 用于屏幕显示的编码，在显示的时候，Vim 会把内部编码转换为屏幕编码，再用于输出。内部编码中含有无法转换为屏幕编码的字符时，该字符会变成问号，但不会影响对它的编辑操作。如果&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;没有设置，则直接使用<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;不进行转换。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">举个例子，当你在 Windows 下通过 telnet 登录 Linux 工作站时，由于 Windows 的 telnet 是 GBK 编码的，而 Linux 下使用 UTF-8 编码，你在 telnet 下的 Vim 中就会乱码。此时有两种消除乱码的方式：一是把 Vim 的&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;改为&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">gbk</code>，另一种方法是保持&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;为&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">utf-8</code>，把&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;改为&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">gbk</code>，让 Vim 在显示的时候转码。显然，使用前一种方法时，如果遇到编辑的文件中含有 GBK 无法表示的字符时，这些字符就会丢失。但如果使用后一种方法，虽然由于终端所限，这些字符无法显示，但在编辑过程中这些字符是不会丢失的。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">对于图形界面下的 GVim，它的显示不依赖 TERM，因此&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;对于它没有意义。在 GTK2 下的 GVim 中，<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;永远是&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">utf-8</code>，并且不能修改。而 Windows 下的 GVim 则忽略&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">termencoding</code>&nbsp;的存在。</p><h1>3&nbsp;fileencoding</h1><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">当 Vim 从磁盘上读取文件的时候，会对文件的编码进行探测。如果文件的编码方式和 Vim 的内部编码方式不同，Vim 就会对编码进行转换。转换完毕后，Vim 会将&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>&nbsp;选项设置为文件的编码。当 Vim 存盘的时候，如果&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">encoding</code>&nbsp;和<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>&nbsp;不一样，Vim 就会进行编码转换。因此，通过打开文件后设置&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>，我们可以将文件由一种编码转换为另一种编码。但是，由前面的介绍可以看出，<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>&nbsp;是在打开文件的时候，由 Vim 进行探测后自动设置的。因此，如果出现乱码，我们无法通过在打开文件后重新设置&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>&nbsp;来纠正乱码。</p><h1>4&nbsp;fileencodings</h1><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">编码的自动识别是通过设置 fileencodings 实现的，注意是复数形式。fileencodings 是一个用逗号分隔的列表，列表中的每一项是一种编码的名称。当我们打开文件的时候，VIM 按顺序使用 fileencodings 中的编码进行尝试解码，如果成功的话，就使用该编码方式进行解码，并将&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencoding</code>&nbsp;设置为这个值，如果失败的话，就继续试验下一个编码。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">因此，我们在设置&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencodings</code>&nbsp;的时候，一定要把要求严格的、当文件不是这个编码的时候更容易出现解码失败的编码方式放在前面，把宽松的编码方式放在后面。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">例如，latin1 是一种非常宽松的编码方式，任何一种编码方式得到的文本，用 latin1 进行解码，都不会发生解码失败&#8212;&#8212;当然，解码得到的结果自然也就是理所当然的&#8220;乱码&#8221;。因此，如果你把&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">latin1</code>&nbsp;放到了&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencodings</code>&nbsp;的第一位的话，打开任何中文文件都是乱码也就是理所当然的了。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">以下是滇狐推荐的一个&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">fileencodings</code>&nbsp;设置：</p><div style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #ffffff; border: 1px solid #808080; margin-left: 2em; margin-right: 2em; padding: 0.5em; font-size: 9pt; overflow: auto; line-height: normal;"><span style="font-weight: bold; color: #a52a2a;">set</span>&nbsp;<span style="color: #800080;">fileencodings</span>=ucs-bom<span style="font-weight: bold; color: #a52a2a;">,</span>utf-8<span style="font-weight: bold; color: #a52a2a;">,</span>cp936<span style="font-weight: bold; color: #a52a2a;">,</span>gb18030<span style="font-weight: bold; color: #a52a2a;">,</span>big5<span style="font-weight: bold; color: #a52a2a;">,</span>euc-jp<span style="font-weight: bold; color: #a52a2a;">,</span>euc-kr<span style="font-weight: bold; color: #a52a2a;">,</span>latin1</div><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">其中，ucs-bom 是一种非常严格的编码，非该编码的文件几乎没有可能被误判为 ucs-bom，因此放在第一位。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">utf-8 也相当严格，除了很短的文件外(例如许多人津津乐道的 GBK 编码的&#8220;联通&#8221;被误判为 UTF-8 编码的经典错误)，现实生活中一般文件是几乎不可能被误判的，因此放在第二位。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">接下来是 cp936 和 gb18030，这两种编码相对宽松，如果放前面的话，会出现大量误判，所以就让它们靠后一些。cp936 的编码空间比 gb18030 小，所以把 cp936 放在 gb18030 前面。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">至于 big5、euc-jp 和 euc-kr，它们的严格程度和 cp936 差不多，把它们放在后面，在编辑这些编码的文件的时候必然出现大量误判，但这是 Vim 内置编码探测机制没有办法解决的事。由于中国用户很少有机会编辑这些编码的文件，因此我们还是决定把 cp936 和 gb18030 前提以保证这些编码的识别。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">最后就是 latin1 了。它是一种极其宽松的编码，以至于我们不得不把它放在最后一位。不过可惜的是，当你碰到一个真的 latin1 编码的文件时，绝大部分情况下，它没有机会 fall-back 到 latin1，往往在前面的编码中就被误判了。不过，正如前面所说的，中国用户没有太多机会接触这样的文件。</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">如果编码被误判了，解码后的结果就无法被人类识别，于是我们就说，这个文件乱码了。此时，如果你知道这个文件的正确编码的话，可以在打开文件的时候使用&nbsp;<code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">++enc=encoding</code>&nbsp;的方式来打开文件，如：</p><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;"><code style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; background-color: #eeeeff;">:e&nbsp;++enc=utf-8&nbsp;myfile.txt</code></p><h1>5&nbsp;fencview</h1><p style="text-indent: 2em; font-family: 'DejaVu Sans', 'Bitstream Vera Sans', 'Lucida Sans', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;">根据前面的介绍，我们知道，通过 Vim 内置的编码识别机制，识别率是很低的，尤其是对于简体中文 (GBK/GB18030)、繁体中文 (Big5)、日文 (euc-jp) 和韩文 (euc-kr) 之间的识别。而对于普通用户而言，肉眼看出一个文件的编码方式也是很不现实的事情。因此，滇狐强烈推荐水木社区的 mbbill 开发的 fencview 插件。该插件使用词频统计的方式识别编码，正确率非常高。点击<a href="http://www.vim.org/scripts/script.php?script_id=1708" style="color: #4080c0; text-decoration: none;">这里</a><a name="idx001" style="color: rgb(64, 128, 192);"></a>&nbsp;下载。</p><img src ="http://www.cppblog.com/zjy17243/aggbug/204973.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2013-12-23 20:04 <a href="http://www.cppblog.com/zjy17243/articles/204973.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux shell实现随机数多种方法（date,random,uuid)(转载)</title><link>http://www.cppblog.com/zjy17243/articles/176620.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Tue, 29 May 2012 07:33:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/176620.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在日常生活中，随机数实际上经常遇到，想丢骰子，抓阄，还有抽签。呵呵，非常简单就可以实现。那么在做程序设计，真的要通过自己程序设计出随机数那还真的不简单了。现在很多都是操作系统内核会提供相应的api，这些原始参数是获取一些计算机运行原始信息，如内存，电压，物理信号等等，它的值在一个时间段可以保证是唯一的了。好了，废话我就不说了。呵呵。&nbsp;&nbsp; shell脚本程序我们有那些获得随机数方...&nbsp;&nbsp;<a href='http://www.cppblog.com/zjy17243/articles/176620.html'>阅读全文</a><img src ="http://www.cppblog.com/zjy17243/aggbug/176620.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2012-05-29 15:33 <a href="http://www.cppblog.com/zjy17243/articles/176620.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux中fork（）函数详解（转载！！实例讲解）</title><link>http://www.cppblog.com/zjy17243/articles/156393.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Wed, 21 Sep 2011 02:34:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/156393.html</guid><wfw:comment>http://www.cppblog.com/zjy17243/comments/156393.html</wfw:comment><comments>http://www.cppblog.com/zjy17243/articles/156393.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zjy17243/comments/commentRss/156393.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zjy17243/services/trackbacks/156393.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;一、fork入门知识&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一个进程，包括代码、数据和分配给进程的资源。fork（）函数通过系统调用创建一个与原来进程几乎完全相同的进程，也就是两个进程可以做完全相同的事，但如果初始参数或者传入的变量不同，两个进程也可以做不同的事。&nbsp;&nbsp;&nbsp; 一个进程调用fork（）函数后，系统先给新的进程分配资源，例如存储...&nbsp;&nbsp;<a href='http://www.cppblog.com/zjy17243/articles/156393.html'>阅读全文</a><img src ="http://www.cppblog.com/zjy17243/aggbug/156393.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2011-09-21 10:34 <a href="http://www.cppblog.com/zjy17243/articles/156393.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>经典vim插件功能说明、安装方法和使用方法介绍（已更新） （转载）</title><link>http://www.cppblog.com/zjy17243/articles/154994.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Sat, 03 Sep 2011 06:49:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/154994.html</guid><wfw:comment>http://www.cppblog.com/zjy17243/comments/154994.html</wfw:comment><comments>http://www.cppblog.com/zjy17243/articles/154994.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zjy17243/comments/commentRss/154994.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zjy17243/services/trackbacks/154994.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1 #============================================================================= &nbsp;&nbsp;2 &nbsp;转载请注明出处:&nbsp;http://blog.csdn.net/tge7618291 &nbsp;&nbsp;8 #======================================...&nbsp;&nbsp;<a href='http://www.cppblog.com/zjy17243/articles/154994.html'>阅读全文</a><img src ="http://www.cppblog.com/zjy17243/aggbug/154994.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2011-09-03 14:49 <a href="http://www.cppblog.com/zjy17243/articles/154994.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vi/vim使用进阶: 使用taglist插件</title><link>http://www.cppblog.com/zjy17243/articles/154954.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Fri, 02 Sep 2011 08:35:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/154954.html</guid><wfw:comment>http://www.cppblog.com/zjy17243/comments/154954.html</wfw:comment><comments>http://www.cppblog.com/zjy17243/articles/154954.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zjy17243/comments/commentRss/154954.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zjy17243/services/trackbacks/154954.html</trackback:ping><description><![CDATA[<div><p>     本节所用命令的帮助入口：   </p> <pre>:help helptags :help taglist.txt </pre> <p>     <a href="http://easwy.com/blog/archives/advanced-vim-skills-use-ctags-tag-file/" target="_blank">上篇文章</a>介绍了在vim中如何使用tag文件，本文主要介绍如何使用taglist插件(plugin)。   </p> <p>     想必用过Source  Insight的人都记得这样一个功能：SI能够把当前文件中的宏、全局变量、函数等tag显示在Symbol窗口，用鼠标点上述tag，就跳到该tag 定义的位置；可以按字母序、该tag所属的类或scope，以及该tag在文件中出现的位置进行排序；如果切换到另外一个文件，Symbol窗口更新显示 这个文件中的tag。   </p> <p>     在vim中的taglist插件所实现的就是上述类似的功能，有些功能比SI弱，有些功能比SI更强。而且，taglist插件还在不断完善中！   </p> <p>     要使用taglist plugin，必须满足：   </p> <div> <ul type="disc"><li>       打开vim的文件类型自动检测功能：<a href="http://easwy.com/blog/archives/advanced-vim-skills-filetype-on/" target="_blank">filetype on</a></li><li>       系统中装了<a href="http://ctags.sourceforge.net/" target="_blank">Exuberant ctags</a>工具，并且taglist plugin能够找到此工具（因为taglist需要调用它来生成tag文件）     </li><li>       你的vim支持system()调用     </li></ul> </div> <p>     在文章<a href="http://easwy.com/blog/archives/advanced-vim-skills-introduce-vimrc/" target="_blank">vimrc初步</a>中，我们使用了vim自带的示例vimrc，这个vimrc中已经打开了文件类型检测功能；在<a href="http://easwy.com/blog/archives/advanced-vim-skills-use-ctags-tag-file/" target="_blank">上篇文章</a>中，我们也已用到了Exuberant ctags；system()调用在一般的vim版本都会支持(suse Linux发行版中出于安全考虑，关闭了此功能)，所以我们已经满足了这三个条件。   </p> <p>     现在我们到<a href="http://www.vim.org/scripts/script.php?script_id=273" target="_top">http://www.vim.org/scripts/script.php?script_id=273</a>下载最新版本的taglist plugin，目前版本是4.3。   </p> <p>     下载后，把该文件在~/.vim/目录中解压缩，这会在你的~/.vim/plugin和~/.vim/doc目录中各放入一个文件：   </p> <pre>plugin/taglist.vim &#8211; taglist插件 doc/taglist.txt    - taglist帮助文件 </pre> <p>     <strong>注：</strong>windows用户需要把这个插件解压在你的$vim/vimfiles或$HOME/vimfiles目录。   </p> <p>     使用下面的命令生成帮助标签（下面的操作在vim中进行）：   </p> <pre>:helptags ~/.vim/doc </pre> <p>     生成帮助标签后，你就可以用下面的命令查看taglist的帮助了：   </p> <pre>:help taglist.txt </pre> <p>     Taglist提供了相当多的功能，我的vimrc中这样配置：   </p> <pre>"""""""""""""""""""""""""""""" " Tag list (ctags) """""""""""""""""""""""""""""" if MySys() == "windows"                "设定windows系统中ctags程序的位置 let Tlist_Ctags_Cmd = 'ctags' elseif MySys() == "linux"              "设定linux系统中ctags程序的位置 let Tlist_Ctags_Cmd = '/usr/bin/ctags' endif let Tlist_Show_One_File = 1            "不同时显示多个文件的tag，只显示当前文件的 let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口，则退出vim let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist窗口 </pre> <p>     这样配置后，当你输入&#8221;<strong>:TlistOpen</strong>&#8220;时，显示如下窗口：   </p> <div><a name="taglist_window"></a> <div align="center"><img src="http://easwy.com/blog/uploads/2009/02/taglist-300x227.jpg" align="middle"  alt="" /></div> <div align="center"><a href="http://easwy.com/blog/uploads/2009/02/taglist.jpg" target="_blank">点击查看大图</a></div> </div> <p>     在屏幕右侧出现的就是taglist窗口，你从中可以看到在main.c文件中定义的所有tag：宏、定义、变量、函数等；你也可以双击某个tag，跳到该tag定义的位置；你还可以把某一类的tag折叠起来（使用了vim的<a href="http://easwy.com/blog/archives/advanced-vim-skills-advanced-move-method/" target="_blank">折行</a>功能），方便查看，就像上图中macro和variable那样。更多的功能，请查看taglist的帮助页，本文也会介绍一些常用功能。   </p> <p>     下面介绍常用的taglist配置选项，你可以根据自己的习惯进行配置：   </p> <div> <ul type="disc"><li><em>Tlist_Ctags_Cmd</em>选项用于指定你的Exuberant ctags程序的位置，如果它没在你PATH变量所定义的路径中，需要使用此选项设置一下；     </li><li> 如果你不想同时显示多个文件中的tag，设置<em>Tlist_Show_One_File</em>为1。缺省为显示多个文件中的tag；     </li><li> 设置<em>Tlist_Sort_Type</em>为&#8221;<strong>name</strong>&#8220;可以使taglist以tag名字进行排序，缺省是按tag在文件中出现的顺序进行排序。按tag出现的范围（即所属的namespace或class）排序，已经加入taglist的TODO List，但尚未支持；     </li><li> 如果你在想taglist窗口是最后一个窗口时退出vim，设置<em>Tlist_Exit_OnlyWindow</em>为1；     </li><li> 如果你想taglist窗口出现在右侧，设置<em>Tlist_Use_Right_Window</em>为1。缺省显示在左侧。     </li><li> 在gvim中，如果你想显示taglist菜单，设置<em>Tlist_Show_Menu</em>为1。你可以使用<em>Tlist_Max_Submenu_Items</em>和<em>Tlist_Max_Tag_Length</em>来控制菜单条目数和所显示tag名字的长度；     </li><li> 缺省情况下，在双击一个tag时，才会跳到该tag定义的位置，如果你想单击tag就跳转，设置<em>Tlist_Use_SingleClick</em>为1；     </li><li> 如果你想在启动vim后，自动打开taglist窗口，设置<em>Tlist_Auto_Open</em>为1；     </li><li> 如果你希望在选择了tag后自动关闭taglist窗口，设置<em>Tlist_Close_On_Select</em>为1；     </li><li> 当同时显示多个文件中的tag时，设置<em>Tlist_File_Fold_Auto_Close</em>为1，可使taglist只显示当前文件tag，其它文件的tag都被折叠起来。     </li><li> 在使用<strong>:TlistToggle</strong>打开taglist窗口时，如果希望输入焦点在taglist窗口中，设置<em>Tlist_GainFocus_On_ToggleOpen</em>为1；     </li><li> 如果希望taglist始终解析文件中的tag，不管taglist窗口有没有打开，设置<em>Tlist_Process_File_Always</em>为1；     </li><li><em>Tlist_WinHeight</em>和<em>Tlist_WinWidth</em>可以设置taglist窗口的高度和宽度。<em>Tlist_Use_Horiz_Window</em>为1设置taglist窗口横向显示；     </li></ul> </div> <p>     在taglist窗口中，可以使用下面的快捷键：   </p> <pre>&lt;CR&gt;          跳到光标下tag所定义的位置，用鼠标双击此tag功能也一样 o             在一个新打开的窗口中显示光标下tag &lt;Space&gt;       显示光标下tag的原型定义 u             更新taglist窗口中的tag s             更改排序方式，在按名字排序和按出现顺序排序间切换 x             taglist窗口放大和缩小，方便查看较长的tag +             打开一个折叠，同zo -             将tag折叠起来，同zc *             打开所有的折叠，同zR =             将所有tag折叠起来，同zM [[            跳到前一个文件 ]]            跳到后一个文件 q             关闭taglist窗口 &lt;F1&gt;          显示帮助 </pre> <p>     可以用&#8221;:<strong>TlistOpen</strong>&#8220;打开taglist窗口，用&#8221;<strong>:TlistClose</strong>&#8220;关闭taglist窗口。或者使用&#8221;<strong>:TlistToggle</strong>&#8220;在打开和关闭间切换。在我的vimrc中定义了下面的映射，使用&lt;F9&gt;键就可以打开/关闭taglist窗口：   </p> <pre>map &lt;silent&gt; &lt;F9&gt; :TlistToggle&lt;cr&gt; </pre> <p>     Taglist插件还提供了很多命令，你甚至可以用这些命令创建一个taglist的会话，然后在下次进入vim时加载此会话。   </p></div><img src ="http://www.cppblog.com/zjy17243/aggbug/154954.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2011-09-02 16:35 <a href="http://www.cppblog.com/zjy17243/articles/154954.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Vim:打造Linux C/C++程序员的编辑器(转载）</title><link>http://www.cppblog.com/zjy17243/articles/154796.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Wed, 31 Aug 2011 08:51:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/154796.html</guid><wfw:comment>http://www.cppblog.com/zjy17243/comments/154796.html</wfw:comment><comments>http://www.cppblog.com/zjy17243/articles/154796.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zjy17243/comments/commentRss/154796.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zjy17243/services/trackbacks/154796.html</trackback:ping><description><![CDATA[<div><span style="color: #009902;">所谓&#8220;工欲善其事，必先利其器&#8221;，所谓&#8220;磨刀不误砍柴工&#8220;。在linux下，<a target="_self"><u><strong>vim</strong></u></a>时一种最常见的编辑器，很多linux的发行版就自带了（不过 Ubuntu目前时需要自己安装的，默认只带了vi）。今天搞了半天了Vim，通过几个插件来武装我的vim，使其能向传说中的一样成为C/C++程序员的利器。</span><br style="color: #009902;" /><span style="color: #009902;">通过配置和插件，实现的功能有：语法高亮+自动缩进+函数自动补全+变量函数的跟踪+列出源代码中的函数变量等</span><br style="color: #009902;" /><span style="color: #009902;">用到的工具有：Vim+.vimrc配置文件+Ctags+taglist</span><br style="color: #009902;" /><span style="color: #009902;">使用效果：http://files.myopera.com/mbbill/files/code_complete.gif</span><br style="color: #009902;" /><span style="color: #009902;">PS：这个效果非常炫的！～</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">vim 下载地址http://www.vim.org&nbsp;&nbsp;&nbsp; ubuntu可使用sudo apt-get install vim</span><br style="color: #009902;" /><span style="color: #009902;">code_complete.vim 插件http://www.vim.org/scripts/script.php?script_id=1764</span><br style="color: #009902;" /><span style="color: #009902;">ctags 一般安装完vim后都会有，ubuntu中好像是不支持，可以通过</span><span style="text-align: center; widows: 2; text-transform. none; text-indent: 0px; border-collapse: separate; font: medium Simsun; white-space: normal; orphans: 2; letter-spacing: normal; color: #000000; word-spacing: 0px;"><span style="text-align: left; line-height: 22px; color: #5e9900; font-size: 14px;">sudo apt-get install ctags 来安装；也可</span></span><span style="color: #009902;">下载:http://www.vim.org/scripts/script.php?script_id=610</span><br style="color: #009902;" /><span style="color: #009902;">taglis 下载:http://www.vim.org/scripts/script.php?script_id=273</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">一. vim 配置</span><br style="color: #009902;" /><span style="color: #009902;">1、配置文件的位置</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp;  在目录 /etc/  下面，有个名为vimrc的文件，这是系统中公共的vim配置文件，对所有用户都有效。而在每个用户的主目录下，都可以自己建立私有的配置文件，命名 为：&#8220;.vimrc&#8221;。例如，/root目录下，通常已经存在一个.vimrc文件。我就在自己的$HOME目录下新建了了.vimrc文件来配置的。 (如果设置/etc/vimrc对所有用户都有效配置，某个userHOME下在.vimrc仅对这个user有效）</span><br style="color: #009902;" /><span style="color: #009902;">2、设置语法高亮显示</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 1) 打开.vimrc，添加以下语句来使得语法高亮显示：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; syntax on</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 2) 如果此时语法还是没有高亮显示，那么在/etc目录下的profile文件中添加以下语句：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; export TERM=xterm-color</span><br style="color: #009902;" /><span style="color: #009902;">3、设置<a target="_self"><u><strong>Windows</strong></u></a>风格的C/C++自动缩进（添加以下set语句到.vimrc中）</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 1）不讨论制表符为8还是为4较好，这里设置（软）制表符宽度为4：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set tabstop=4</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set softtabstop=4</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 2）设置缩进的空格数为4</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set shiftwidth=4</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 3）设置自动缩进：即每行的缩进值与上一行相等；使用 noautoindent 取消设置：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set autoindent</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 4）设置使用 C/C++ 语言的自动缩进方式：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set cindent</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 5）设置C/C++语言的具体缩进方式（以我的windows风格为例）：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,&gt;1s,=1s,:1s</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 6）如果想在左侧显示文本的行号，可以用以下语句：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set nu</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 7）最后，如果没有下列语句，就加上吧：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; if &amp;term=="xterm"</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp;&nbsp;&nbsp; set t_Co=8</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp;&nbsp;&nbsp; set t_Sb=^[[4%dm</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp;&nbsp;&nbsp; set t_Sf=^[[3%dm</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; endif</span><br style="color: #009902;" /><span style="color: #009902;">PS：自动缩进有两个选项，代码:</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; set autoindent 与&nbsp; set cindent</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp;  autoindent 就是自动缩进的意思，当你在输入状态用回车键插入一个新行，或者在 normal 状态用 o 或者 O  插入一个新行时，autoindent  会自动地将当前行的缩进拷贝到新行，也就是"自动对齐&#8221;，当然了，如果你在新行没有输入任何字符，那么这个缩进将自动删除。</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; cindent 就不同了，它会按照 C 语言的语法，自动地调整缩进的长度，比如，当你输入了半条语句然后回车时，缩进会自动增加一个 TABSTOP 值，当你键入了一个右花括号时，会自动减少一个 TABSTOP 值。</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">二. code_complete 配置</span><br style="color: #009902;" /><span style="color: #009902;">把下载的code_complete.vim拷贝到plugin目录下，一般都在(我的是)/usr/share/vim/vim72/plugin下 （不同的vim版本vim72可能时<a target="_self"><u><strong>其他</strong></u></a>，我的目前时7.2版本）</span><br style="color: #009902;" /><span style="color: #009902;">在vim中使用&lt;tab&gt;键就可以补全函数原型了。具体不全的快捷键的定义，如果in代表#include " "，见：code_complete.vim文件中的定义。</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">三. 用ctags命令生成tags文件，ctags -R --c-kinds=+p --fields=+S /usr/include 应该算是建立索引表（默认会在当前目录生成tags文件），然后把生成的tags文件拷贝到你编程的目录。</span><br style="color: #009902;" /><span style="color: #009902;">注意：ctags -R 后面不加上绝对路径，就时建立当前目录的下所有文件的索引，那么建立的索引文件中都是写的相对路径，你将tags文件拷贝到其他目录去用时，它就会找不到相应的函数/变量等。</span><br style="color: #009902;" /><span style="color: #009902;">"-R"表示递归创建，也就包括源代码根目录下的所有子目录下的源程序。</span><br style="color: #009902;" /><span style="color: #009902;">"tags"文件中包括这些对象的列表：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 用#define定义的宏</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 枚举型变量的值</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 函数的定义、原型和声明</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 名字空间（namespace）</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 类型定义（typedefs）</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 变量（包括定义和声明）</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 类（class）、结构（struct）、枚举类型（enum）和联合（union）</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 类、结构和联合中成员变量或函数</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; VIM用这个"tags"文件来定位上面这些做了标记的对象，下面介绍一下定位这些对象的方法：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 1) 用命令行。在运行vim的时候加上"-t"参数，例如：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; [/home/admin/src]$ vim -t foo_bar</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 这个命令将打开定义"foo_bar"（变量或函数或<a target="_self"><u><strong>其它</strong></u></a>）的文件，并把光标定位到这一行。</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 2) 在vim编辑器内用":ta"命令，例如：</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; :ta foo_bar</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 3) 最方便的方法是把光标移到变量名或函数名上，然后按下"Ctrl-]"。用"Ctrl-o"退回原来的地方。</span><br style="color: #009902;" /><span style="color: #009902;">&nbsp; 注意：运行vim的时候，必须在"tags"文件所在的目录下运行。否则，运行vim的时候还要用":set tags="命令设定"tags"文件的路径，这样vim才能找到"tags"文件。</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">四. taglist的配置和使用</span><br style="color: #009902;" /><span style="color: #009902;">下载taglist压缩包，并解压，cp plugin/taglist.vim /usr/share/vim/vim72/plugin/ ; cp doc/taglist.txt /usr/share/vim/vim61/doc/</span><br style="color: #009902;" /><span style="color: #009902;">启动vim，用 &#8220;:helptags .&#8221;来配置好帮助文件；重启vim，用&#8220;:TlistToggle&#8221;来打开和关闭taglist窗口；可以用&#8220;:help taglist&#8221;来获得更多帮助信</span><br style="color: #009902;" /><br style="color: #009902;" /><span style="color: #009902;">参考资料：</span><br style="color: #009902;" /><span style="color: #009902;">http://blog.chinaunix.net/u2/74761/showart_1096872.html</span><br style="color: #009902;" /><span style="color: #009902;">http://www.linuxsir.org/bbs/showthread.php?p=2095747#post2095747&nbsp;&nbsp;&nbsp; （vim很强大功能介绍）</span><br style="color: #009902;" /><span style="color: #009902;">http://linux.chinaunix.net/bbs/thread-1036769-1-1.html</span><br style="color: #009902;" /><span style="color: #009902;">http://blog.chinaunix.net/u/553/showart_288387.html</span></div><img src ="http://www.cppblog.com/zjy17243/aggbug/154796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2011-08-31 16:51 <a href="http://www.cppblog.com/zjy17243/articles/154796.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>轻松解决Linux安装Eclipse方法</title><link>http://www.cppblog.com/zjy17243/articles/152205.html</link><dc:creator>月下孤影</dc:creator><author>月下孤影</author><pubDate>Mon, 01 Aug 2011 04:41:00 GMT</pubDate><guid>http://www.cppblog.com/zjy17243/articles/152205.html</guid><description><![CDATA[<div><span style="color: #333333; font-family: 宋体; line-height: 28px; "><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">随着Linux的发展，很多人开始学习Linux系统，你了解Linux系统么？你是Linux系统的应用者么？本文为你详细介绍Linux安装Eclipse，为你在学习Linux安装Eclipse时起一定的作用。以下是Linux安装Eclipse完全攻略。</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">1. ubuntu 下安装Eclipse&nbsp;<br style="clear: both; width: 0px; height: 0px; " />1.1 在Ubuntu搭建java开发环境&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(1)安装好Ubuntu系统；安装的时候强烈建议连接上网，它会自动下载语言包，自动装上五笔，拼 音，还有会默认把firefox浏览器设置为中文.&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(2)配置Ubuntu环境：添加源，更新软件信息，升级内核&nbsp;<br style="clear: both; width: 0px; height: 0px; " />可以参考网上的一篇文章：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />http://hi.baidu.com/myownroom/blog/category/Linux&nbsp;<br style="clear: both; width: 0px; height: 0px; " />$ sudo apt-get update&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(3)安装jdk软件包&nbsp;<br style="clear: both; width: 0px; height: 0px; " />sudo apt-get install sun-java6-jdk&nbsp;<br style="clear: both; width: 0px; height: 0px; " />大约过了二十分钟会提示安装jdk成功信息，这时候你可以在shell打入java或javac看一看，看一下显示的信息有显示（这里显示的是jdk版本号，如果系统自带的有gdk，需要注意一下），证明jdk安装成功.&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（正在设定 sun-java6-jre 不动了&#8230;&#8230;&nbsp;<br style="clear: both; width: 0px; height: 0px; " />怎么办？\"确定\"选项明明就在，但是狂按回车没反应&#8230;&#8230;&nbsp;<br style="clear: both; width: 0px; height: 0px; " />网上一查，按tab键，\"确定\"变红，再按回车，ok了)&nbsp;<br style="clear: both; width: 0px; height: 0px; " />接下来的工作是，配置JRE环境:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />在shell执行:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />sudo update-alternatives --config java&nbsp;<br style="clear: both; width: 0px; height: 0px; " />通常会给出两个或两个以上选择的路径&nbsp;<br style="clear: both; width: 0px; height: 0px; " />选择：/usr/lib/jvm/java-1.6.0-sun/jre/bin/java作为你的JRE&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（4）建议安装安装浏览器Java插件(不是必要的)：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />在shell中执行:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />sudo apt-get install sun-java6-plugin&nbsp;<br style="clear: both; width: 0px; height: 0px; " />1.2 在ubuntu下安装eclipse。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（1）到http://www.eclipse.org/downloads/，下载eclipse for linux版本，我下载后文件的完整名称为:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />eclipse-java-galileo-SR1-linux-gtk.tar.gz&nbsp;<br style="clear: both; width: 0px; height: 0px; " />解压缩后，可以查看根目录下的&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(2)将eclipse-SDK-3.2.1-linux-gtk.tar.gz这一个文件放到/opt目录下面（用root执行mv _ _语句才能移进opt文件夹）&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(3)在shell中进入/opt/，执行： tar －zxvf eclipse-SDK-4.2.1-linux-gtk.tar.gz语句，解压缩下载文件&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(4)在shell中，进入到eclipse 目录，cd /opt/eclipse&nbsp;<br style="clear: both; width: 0px; height: 0px; " />设置文件eclipse执行权：chown -R root:你的用户名 eclipse&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(5)创建桌面连接&nbsp;<br style="clear: both; width: 0px; height: 0px; " />sudo gedit /usr/share/applications/eclipse.desktop&nbsp;<br style="clear: both; width: 0px; height: 0px; " />加入下面内容&nbsp;<br style="clear: both; width: 0px; height: 0px; " />[Desktop Entry] Encoding=UTF-8 Name=Eclipse Comment=Eclipse SDK Exec=/opt/eclipse/eclipse Icon=/opt/eclipse/icon.xpm Terminal=false Type=Application Categories=Application;Development;&nbsp;<br style="clear: both; width: 0px; height: 0px; " />这时就会在最左上角的应用程序菜单加多一个\"编程\"--&gt;\"eclipse\"的菜单，点击即可起动eclipse.&nbsp;<br style="clear: both; width: 0px; height: 0px; " />提示：如果点击\"编程\"--&gt;\"eclipse\"的菜单提示编码错误，就在桌面上自己建一个启动器指向eclipse安装目录即可..&nbsp;<br style="clear: both; width: 0px; height: 0px; " />参考网址：http://www.javaeye.com/topic/34636</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">2. Redhat 下安装Eclipse&nbsp;<br style="clear: both; width: 0px; height: 0px; " />参考：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（1）http://collonn.javaeye.com/blog/436427&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（2）http://hi.baidu.com/summerytyj/blog/item/58ca9801b 4cb78d3267fb579.html&nbsp;<br style="clear: both; width: 0px; height: 0px; " />RedHat上安装jdk&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第一步：如果原来机子上安装的有RedHat，需要首先卸载RedHat自带的JDK。因为版本比较新的eclipse可能需要比较新的jdk版本。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />rpm -qa | grep gcj&nbsp;<br style="clear: both; width: 0px; height: 0px; " />#会列出一些东西如：java-1.4.2-gcj-compat-1.4.2.0-27jpp等，我们只删除含有java字串的软件包&nbsp;<br style="clear: both; width: 0px; height: 0px; " />rpm -e java-1.4.2-gcj-compat-1.4.2.0-27jpp&nbsp;<br style="clear: both; width: 0px; height: 0px; " />#或者：rpm -e --nodeps java 也可以：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />但是这样删除的时候可能会遇到一些问题，主要是有关依赖包的问题。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />这可以在Applications-&gt;Add and Remove Software中找到java开头的包进行删除。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第二步：安装jdk（无论是eclipse c/c++还是eclipse java，都需要jdk）&nbsp;<br style="clear: both; width: 0px; height: 0px; " />在sun官网上下载对应操作系统的jdk。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />一般有两种格式的文件。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第三步：安装eclipse。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />解压电机eclipse可执行文件即可。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第四步：在桌面上添加eclipse图标&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（1）编写.sh文件&nbsp;<br style="clear: both; width: 0px; height: 0px; " />export JAVA_HOME = /usr/java/（jdk安装文件夹）&nbsp;<br style="clear: both; width: 0px; height: 0px; " />export PATH = $JAVA_HOME/bin:$PATH&nbsp;<br style="clear: both; width: 0px; height: 0px; " />CLASSPATH=.:/usr/java/j2sdk1.4.2_01/lib/tools.jar: $CLASSPATH&nbsp;<br style="clear: both; width: 0px; height: 0px; " />export CLASSPATH&nbsp;<br style="clear: both; width: 0px; height: 0px; " />opt/eclipse/eclipse（此为eclipse解压缩文件所在目录） -vm /usr/java/（jdk安装文件夹） /bin/java -data ~/workspace &amp;&nbsp;<br style="clear: both; width: 0px; height: 0px; " />create launch from desktop:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(1)entry derectory:/usr/share/applications/&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(2)gedit eclipse.destop&nbsp;<br style="clear: both; width: 0px; height: 0px; " />[Desktop Entry] Encoding=UTF-8 Name=EclipseC++ Type=Application Terminal=false Exec=/opt/eclipseC++/eclipse -vm /opt/jdk1.6.0_16/bin/java -data ~/workspaceC++ Icon=/opt/eclipseC++/icon.xpm Categories=Apllication;Development;&nbsp;<br style="clear: both; width: 0px; height: 0px; " />（2）在桌面上右键单击，选择create launcher，然后选择上述编写的.sh文件。这时，桌面上就会出现eclipse可执行文件。点击即可运行。</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">3. 配置tomcat&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第一步：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />下载eclipse tomcat插件：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />http://www.eclipsetotale.com/tomcatPlugin.html&nbsp;<br style="clear: both; width: 0px; height: 0px; " />将该插件解压后放到eclipse的plugins目录下。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />第二步：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />下载tomcat：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />http://tomcat.apache.org/&nbsp;<br style="clear: both; width: 0px; height: 0px; " />重启eclipse即可看到tomcat的图标。</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">4. MySQL:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />download address:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />http://dev.mysql.com/downloads/&nbsp;<br style="clear: both; width: 0px; height: 0px; " />access denied (java.util.PropertyPermission catalina.home read&nbsp;<br style="clear: both; width: 0px; height: 0px; " />Window-&gt;Preferences-&gt; Tomcat&nbsp;<br style="clear: both; width: 0px; height: 0px; " />Advanced-&gt;Launch Tomcat Using Sacrity Manager(don not choose）</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">5. MyEclipse:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />download wensite：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />http://www.verycd.com/topics/2741105/&nbsp;<br style="clear: both; width: 0px; height: 0px; " />ed2k://|file|[J2EE.集成开发环境].TLF-SOFT-MyEclipse.Enterprise.Workbench.v7.1.1-R iFT.nfo|3943|1bb19755c5394a0fd8ff7592ca909d04|h=JBB AC3WAD444UT3MP2RURLNVMZXQLFEQ|/&nbsp;<br style="clear: both; width: 0px; height: 0px; " />reference：http://blog.sina.com.cn/s/blog_45fd882f0100cjsx.ht ml&nbsp;<br style="clear: both; width: 0px; height: 0px; " />have downloaded the MyEclipse ， I input&nbsp;<br style="clear: both; width: 0px; height: 0px; " />$ sudo chmod 777 MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bin<br style="clear: both; width: 0px; height: 0px; " />$ ./MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86- RiFT.bin&nbsp;<br style="clear: both; width: 0px; height: 0px; " />bash: ./MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86- RiFT.bin：无法执行二进制文件&nbsp;<br style="clear: both; width: 0px; height: 0px; " />$ sh MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bi n&nbsp;<br style="clear: both; width: 0px; height: 0px; " />MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bin: 1: Syntax error: \"&amp;\" unexpected (expecting \")\")&nbsp;<br style="clear: both; width: 0px; height: 0px; " />I do not know how to solve it，the quit.&nbsp;<br style="clear: both; width: 0px; height: 0px; " />But I still can develop web applications on eclipse.</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">6. Start Web Development&nbsp;<br style="clear: both; width: 0px; height: 0px; " />Reference：http://cwiki.apache.org/WW/setting-up-eclipse-with -tomcat.html</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">(1)Help-&gt;Install new software&nbsp;<br style="clear: both; width: 0px; height: 0px; " />-&gt;Available Software&nbsp;<br style="clear: both; width: 0px; height: 0px; " />input the website: \"http://download.eclipse.org/releases/galileo\"&nbsp;<br style="clear: both; width: 0px; height: 0px; " />choose \"WEB，XML，Java EE Development\"&nbsp;<br style="clear: both; width: 0px; height: 0px; " />the plugin can help create web applications， including JavaScript， XML， XSL， XSD， HTML， XHTML， CSS， JSP， EJBs， Webservices， and JPA tools</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">（2）define server：&nbsp;<br style="clear: both; width: 0px; height: 0px; " />new -&gt; server&nbsp;<br style="clear: both; width: 0px; height: 0px; " />tomcat 5.0&nbsp;<br style="clear: both; width: 0px; height: 0px; " />(It do not support for tomcat 5.5 and 6.0， so I can just use tomcat 5.0)</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">(3) restart the eclipse&nbsp;<br style="clear: both; width: 0px; height: 0px; " />new-&gt; project&nbsp;<br style="clear: both; width: 0px; height: 0px; " />input:\"web\"&nbsp;<br style="clear: both; width: 0px; height: 0px; " />choose \"Dynamic Website\"</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">(4) add new html to \"web \" project&nbsp;<br style="clear: both; width: 0px; height: 0px; " />&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"&gt; &lt;html&gt; &lt;head&gt; &lt;mce:script type=\"text/javascript\"&gt;&lt;!-- function hello(){ alert(\"hello\"); } // --&gt;&lt;/mce:script&gt; &lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;input type=\"text\" id=\"input1\" &gt;&lt;/input&gt; &lt;br&gt;&lt;/br&gt; &lt;input type=\"button\" value=\"submit\" onClick=\"hello()\"&gt;&lt;/input&gt; &lt;/body&gt; &lt;/html&gt;</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">(5) 选中web工程，右键单击。&nbsp;<br style="clear: both; width: 0px; height: 0px; " />Run as -&gt; Run on server&nbsp;<br style="clear: both; width: 0px; height: 0px; " />choose tomcat5.0&nbsp;<br style="clear: both; width: 0px; height: 0px; " />input website :\"http://localhost:8080/web/index.html\"&nbsp;<br style="clear: both; width: 0px; height: 0px; " />you will find you have got much seccess!</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">(6)add new servnet for the project:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />new -&gt; servlet，&nbsp;<br style="clear: both; width: 0px; height: 0px; " />name:helloservlet&nbsp;<br style="clear: both; width: 0px; height: 0px; " />import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class for Servlet: HelloServlet * */ public class helloservlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ public helloservlet() { super(); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doGet(HttpServletRe quest request， HttpServletResponse response) */ protected void doGet(HttpServletRequest request， HttpServletResponse response) throws ServletException， IOException { response.getWriter().write(\"Hello， world!\"); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doPost(HttpServletR equest request， HttpServletResponse response) */ protected void doPost(HttpServletRequest request， HttpServletResponse response) throws ServletException， IOException { // TODO Auto-generated method stub } }&nbsp;<br style="clear: both; width: 0px; height: 0px; " />restart the eclipse，and run on server，&nbsp;<br style="clear: both; width: 0px; height: 0px; " />input web site:\"http://127.0.0.1:8080/web/hellowervlet\"&nbsp;<br style="clear: both; width: 0px; height: 0px; " />you will see:&nbsp;<br style="clear: both; width: 0px; height: 0px; " />Hello， world!</p><p style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; background-color: transparent; text-indent: 28px; ">这样就你学会了Linux安装Eclipse。</p></span></div><img src ="http://www.cppblog.com/zjy17243/aggbug/152205.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zjy17243/" target="_blank">月下孤影</a> 2011-08-01 12:41 <a href="http://www.cppblog.com/zjy17243/articles/152205.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>