vim高亮

原文地址http://blog.csdn.net/g_brightboy/article/details/14229139

簡介】

      爲了更加方便的學習和研究一個開源c++項目(當然linux環境下),特地花了一兩週的時間研究vim及其插件的配置和使用方法,整理出來:一來做個記錄便於日後回顧查看,二來分享出來爲大家提供方便。
vim是什麼
      vim是一款功能強大、支持各種插件、配置極爲靈活的編輯器,且支持多種主流OS(linux、Unix、mac、windows),可用來各種編程預言的coding和文件編輯,用習慣了vim,你會體會到它是如此的高效和便捷。引用官網(
www.vim.org)上vim的自我介紹說:
Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems.Vim is often called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files. Despite what the above comic suggests, Vim can be configured to work in a very simple (Notepad-like) way, called evim or Easy Vim.”
      本文主要通過一些示例介紹下如何定製自己專屬的基於vim的IDE編程環境(主要針對c/c++,其他語言亦可採用相同的思路)。下面我們就一步一步來介紹,一磚一瓦從零開始建造我們基於VIM的友好的IDE環境。

【vim的下載與安裝】

1. 在線安裝

直接shell中輸入如下命令:

[plain] view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. sudo apt-get install vim (ubuntu)  
  2. yum install vim (redHat/Fedora/CentOS)  

linux會自動檢測並下載安裝。

2 手動下載編譯安裝

      截止當前最新版本是7.4(vim-7.4.tar.bz2),可在windows環境下載好,拷貝至linux環境安裝,或直接linux命令行下載。這裏給出 linux直接下載並編譯安裝(以下均爲shell命令):
1). wget下載
wget 
ftp://ftp.vim.org/ftp/pub/vim/unix/vim-7.4.tar.bz2
(或用ftp命令登陸ftp://ftp.vim.org,get命令獲取)

2). 解壓 
bunzip2 vim-7.4.tar.bz2

3). 解壓 
tar xvf vim-7.4.tar

4). 進入vim74(解壓後的)目錄,執行
./configure --disable-selinux --enable-cscope
(./configure -help 查看後面參數選項的含義)

5). 編譯
make

6). 安裝
make install

只要不出現error即代表成功安裝,也可直接用vim命令來檢測,或whatis vim(whereis vim)查看。通常情況下,許多發行版會默認安裝vim,則可省略上述步驟。

【vim的初始化配置.vimrc】

1. 存放位置

      linux環境下vim的初始化配置文件爲.vimrc, 通常有兩個:系統版本和用戶版本,前者不同發行版linux會有不同,一般位於/etc/vimrc,是整個系統vim的默認配置;後者位於~/.vimrc,是當前用戶的vim配置,會覆蓋系統配置。關於vim的其他配置參數文件位於/usr/local/share/vim/下,可進入vim,在命令模式下鍵入
:version (查看基本配置路徑)
:echo $VIM
:echo $HOME(查看具體路徑值)
~/.vimrc有時並不存在,此時用戶可以建立一個.vimrc,放入主目錄以實現自己的vim配置。

2. 主要命令參數
      .vimrc通常用於指定vim的編輯參數和外觀環境。下面列出常用的命令參數及其含義:

<a target=_blank id="L1" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;">   1</a>
<a target=_blank id="L2" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;">   2</a>
<a target=_blank id="L3" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;">   3</a>
<a target=_blank id="L4" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;">   4</a>
<a target=_blank id="L5" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;">   5</a>
<a target=_blank id="L6" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;">   6</a>
<a target=_blank id="L7" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;">   7</a>
<a target=_blank id="L8" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;">   8</a>
<a target=_blank id="L9" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;">   9</a>
<a target=_blank id="L10" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;">  10</a>
<a target=_blank id="L11" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;">  11</a>
<a target=_blank id="L12" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;">  12</a>
<a target=_blank id="L13" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;">  13</a>
<a target=_blank id="L14" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;">  14</a>
<a target=_blank id="L15" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;">  15</a>
<a target=_blank id="L16" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;">  16</a>
<a target=_blank id="L17" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;">  17</a>
<a target=_blank id="L18" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;">  18</a>
<a target=_blank id="L19" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;">  19</a>
<a target=_blank id="L20" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;">  20</a>
<a target=_blank id="L21" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;">  21</a>
<a target=_blank id="L22" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;">  22</a>
<a target=_blank id="L23" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;">  23</a>
<a target=_blank id="L24" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;">  24</a>
<a target=_blank id="L25" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;">  25</a>
<a target=_blank id="L26" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;">  26</a>
<a target=_blank id="L27" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;">  27</a>
<a target=_blank id="L28" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;">  28</a>
<a target=_blank id="L29" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;">  29</a>
<a target=_blank id="L30" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;">  30</a>
<a target=_blank id="L31" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;">  31</a>
<a target=_blank id="L32" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;">  32</a>
<a target=_blank id="L33" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;">  33</a>
<a target=_blank id="L34" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;">  34</a>
<a target=_blank id="L35" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;">  35</a>
<a target=_blank id="L36" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;">  36</a>
<a target=_blank id="L37" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;">  37</a>
<a target=_blank id="L38" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;">  38</a>
<a target=_blank id="L39" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;">  39</a>
<a target=_blank id="L40" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L40" rel="#L40" style="color: rgb(102, 102, 102); text-decoration: none;">  40</a>
<a target=_blank id="L41" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L41" rel="#L41" style="color: rgb(102, 102, 102); text-decoration: none;">  41</a>
<a target=_blank id="L42" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L42" rel="#L42" style="color: rgb(102, 102, 102); text-decoration: none;">  42</a>
<a target=_blank id="L43" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L43" rel="#L43" style="color: rgb(102, 102, 102); text-decoration: none;">  43</a>
<a target=_blank id="L44" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L44" rel="#L44" style="color: rgb(102, 102, 102); text-decoration: none;">  44</a>
<a target=_blank id="L45" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L45" rel="#L45" style="color: rgb(102, 102, 102); text-decoration: none;">  45</a>
<a target=_blank id="L46" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L46" rel="#L46" style="color: rgb(102, 102, 102); text-decoration: none;">  46</a>
<a target=_blank id="L47" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L47" rel="#L47" style="color: rgb(102, 102, 102); text-decoration: none;">  47</a>
<a target=_blank id="L48" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L48" rel="#L48" style="color: rgb(102, 102, 102); text-decoration: none;">  48</a>
<a target=_blank id="L49" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L49" rel="#L49" style="color: rgb(102, 102, 102); text-decoration: none;">  49</a>
<a target=_blank id="L50" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L50" rel="#L50" style="color: rgb(102, 102, 102); text-decoration: none;">  50</a>
<a target=_blank id="L51" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L51" rel="#L51" style="color: rgb(102, 102, 102); text-decoration: none;">  51</a>
<a target=_blank id="L52" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L52" rel="#L52" style="color: rgb(102, 102, 102); text-decoration: none;">  52</a>
<a target=_blank id="L53" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L53" rel="#L53" style="color: rgb(102, 102, 102); text-decoration: none;">  53</a>
<a target=_blank id="L54" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L54" rel="#L54" style="color: rgb(102, 102, 102); text-decoration: none;">  54</a>
<a target=_blank id="L55" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L55" rel="#L55" style="color: rgb(102, 102, 102); text-decoration: none;">  55</a>
<a target=_blank id="L56" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L56" rel="#L56" style="color: rgb(102, 102, 102); text-decoration: none;">  56</a>
<a target=_blank id="L57" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L57" rel="#L57" style="color: rgb(102, 102, 102); text-decoration: none;">  57</a>
<a target=_blank id="L58" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L58" rel="#L58" style="color: rgb(102, 102, 102); text-decoration: none;">  58</a>
<a target=_blank id="L59" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L59" rel="#L59" style="color: rgb(102, 102, 102); text-decoration: none;">  59</a>
<a target=_blank id="L60" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L60" rel="#L60" style="color: rgb(102, 102, 102); text-decoration: none;">  60</a>
<a target=_blank id="L61" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L61" rel="#L61" style="color: rgb(102, 102, 102); text-decoration: none;">  61</a>
<a target=_blank id="L62" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L62" rel="#L62" style="color: rgb(102, 102, 102); text-decoration: none;">  62</a>
<a target=_blank id="L63" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L63" rel="#L63" style="color: rgb(102, 102, 102); text-decoration: none;">  63</a>
<a target=_blank id="L64" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L64" rel="#L64" style="color: rgb(102, 102, 102); text-decoration: none;">  64</a>
<a target=_blank id="L65" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L65" rel="#L65" style="color: rgb(102, 102, 102); text-decoration: none;">  65</a>
<a target=_blank id="L66" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L66" rel="#L66" style="color: rgb(102, 102, 102); text-decoration: none;">  66</a>
<a target=_blank id="L67" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L67" rel="#L67" style="color: rgb(102, 102, 102); text-decoration: none;">  67</a>
<a target=_blank id="L68" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L68" rel="#L68" style="color: rgb(102, 102, 102); text-decoration: none;">  68</a>
<a target=_blank id="L69" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L69" rel="#L69" style="color: rgb(102, 102, 102); text-decoration: none;">  69</a>
<a target=_blank id="L70" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L70" rel="#L70" style="color: rgb(102, 102, 102); text-decoration: none;">  70</a>
<a target=_blank id="L71" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L71" rel="#L71" style="color: rgb(102, 102, 102); text-decoration: none;">  71</a>
<a target=_blank id="L72" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L72" rel="#L72" style="color: rgb(102, 102, 102); text-decoration: none;">  72</a>
<a target=_blank id="L73" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L73" rel="#L73" style="color: rgb(102, 102, 102); text-decoration: none;">  73</a>
<a target=_blank id="L74" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L74" rel="#L74" style="color: rgb(102, 102, 102); text-decoration: none;">  74</a>
<a target=_blank id="L75" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L75" rel="#L75" style="color: rgb(102, 102, 102); text-decoration: none;">  75</a>
<a target=_blank id="L76" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L76" rel="#L76" style="color: rgb(102, 102, 102); text-decoration: none;">  76</a>
<a target=_blank id="L77" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L77" rel="#L77" style="color: rgb(102, 102, 102); text-decoration: none;">  77</a>
<a target=_blank id="L78" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L78" rel="#L78" style="color: rgb(102, 102, 102); text-decoration: none;">  78</a>
<a target=_blank id="L79" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L79" rel="#L79" style="color: rgb(102, 102, 102); text-decoration: none;">  79</a>
<a target=_blank id="L80" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L80" rel="#L80" style="color: rgb(102, 102, 102); text-decoration: none;">  80</a>
<a target=_blank id="L81" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L81" rel="#L81" style="color: rgb(102, 102, 102); text-decoration: none;">  81</a>
<a target=_blank id="L82" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L82" rel="#L82" style="color: rgb(102, 102, 102); text-decoration: none;">  82</a>
<a target=_blank id="L83" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L83" rel="#L83" style="color: rgb(102, 102, 102); text-decoration: none;">  83</a>
<a target=_blank id="L84" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L84" rel="#L84" style="color: rgb(102, 102, 102); text-decoration: none;">  84</a>
<a target=_blank id="L85" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L85" rel="#L85" style="color: rgb(102, 102, 102); text-decoration: none;">  85</a>
<a target=_blank id="L86" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L86" rel="#L86" style="color: rgb(102, 102, 102); text-decoration: none;">  86</a>
<a target=_blank id="L87" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L87" rel="#L87" style="color: rgb(102, 102, 102); text-decoration: none;">  87</a>
<a target=_blank id="L88" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L88" rel="#L88" style="color: rgb(102, 102, 102); text-decoration: none;">  88</a>
<a target=_blank id="L89" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L89" rel="#L89" style="color: rgb(102, 102, 102); text-decoration: none;">  89</a>
<a target=_blank id="L90" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L90" rel="#L90" style="color: rgb(102, 102, 102); text-decoration: none;">  90</a>
<a target=_blank id="L91" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L91" rel="#L91" style="color: rgb(102, 102, 102); text-decoration: none;">  91</a>
<a target=_blank id="L92" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L92" rel="#L92" style="color: rgb(102, 102, 102); text-decoration: none;">  92</a>
<a target=_blank id="L93" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L93" rel="#L93" style="color: rgb(102, 102, 102); text-decoration: none;">  93</a>
<a target=_blank id="L94" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L94" rel="#L94" style="color: rgb(102, 102, 102); text-decoration: none;">  94</a>
<a target=_blank id="L95" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L95" rel="#L95" style="color: rgb(102, 102, 102); text-decoration: none;">  95</a>
<a target=_blank id="L96" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L96" rel="#L96" style="color: rgb(102, 102, 102); text-decoration: none;">  96</a>
<a target=_blank id="L97" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L97" rel="#L97" style="color: rgb(102, 102, 102); text-decoration: none;">  97</a>
<a target=_blank id="L98" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L98" rel="#L98" style="color: rgb(102, 102, 102); text-decoration: none;">  98</a>
<a target=_blank id="L99" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L99" rel="#L99" style="color: rgb(102, 102, 102); text-decoration: none;">  99</a>
<a target=_blank id="L100" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L100" rel="#L100" style="color: rgb(102, 102, 102); text-decoration: none;"> 100</a>
<a target=_blank id="L101" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L101" rel="#L101" style="color: rgb(102, 102, 102); text-decoration: none;"> 101</a>
<a target=_blank id="L102" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L102" rel="#L102" style="color: rgb(102, 102, 102); text-decoration: none;"> 102</a>
<a target=_blank id="L103" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L103" rel="#L103" style="color: rgb(102, 102, 102); text-decoration: none;"> 103</a>
<a target=_blank id="L104" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L104" rel="#L104" style="color: rgb(102, 102, 102); text-decoration: none;"> 104</a>
<a target=_blank id="L105" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L105" rel="#L105" style="color: rgb(102, 102, 102); text-decoration: none;"> 105</a>
<a target=_blank id="L106" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L106" rel="#L106" style="color: rgb(102, 102, 102); text-decoration: none;"> 106</a>
<a target=_blank id="L107" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L107" rel="#L107" style="color: rgb(102, 102, 102); text-decoration: none;"> 107</a>
<a target=_blank id="L108" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L108" rel="#L108" style="color: rgb(102, 102, 102); text-decoration: none;"> 108</a>
<a target=_blank id="L109" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L109" rel="#L109" style="color: rgb(102, 102, 102); text-decoration: none;"> 109</a>
<a target=_blank id="L110" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L110" rel="#L110" style="color: rgb(102, 102, 102); text-decoration: none;"> 110</a>
<a target=_blank id="L111" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L111" rel="#L111" style="color: rgb(102, 102, 102); text-decoration: none;"> 111</a>
<a target=_blank id="L112" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L112" rel="#L112" style="color: rgb(102, 102, 102); text-decoration: none;"> 112</a>
<a target=_blank id="L113" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L113" rel="#L113" style="color: rgb(102, 102, 102); text-decoration: none;"> 113</a>
<a target=_blank id="L114" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L114" rel="#L114" style="color: rgb(102, 102, 102); text-decoration: none;"> 114</a>
<a target=_blank id="L115" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L115" rel="#L115" style="color: rgb(102, 102, 102); text-decoration: none;"> 115</a>
<a target=_blank id="L116" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L116" rel="#L116" style="color: rgb(102, 102, 102); text-decoration: none;"> 116</a>
<a target=_blank id="L117" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L117" rel="#L117" style="color: rgb(102, 102, 102); text-decoration: none;"> 117</a>
<a target=_blank id="L118" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L118" rel="#L118" style="color: rgb(102, 102, 102); text-decoration: none;"> 118</a>
<a target=_blank id="L119" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L119" rel="#L119" style="color: rgb(102, 102, 102); text-decoration: none;"> 119</a>
<a target=_blank id="L120" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L120" rel="#L120" style="color: rgb(102, 102, 102); text-decoration: none;"> 120</a>
<a target=_blank id="L121" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L121" rel="#L121" style="color: rgb(102, 102, 102); text-decoration: none;"> 121</a>
<a target=_blank id="L122" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L122" rel="#L122" style="color: rgb(102, 102, 102); text-decoration: none;"> 122</a>
<a target=_blank id="L123" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L123" rel="#L123" style="color: rgb(102, 102, 102); text-decoration: none;"> 123</a>
<a target=_blank id="L124" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L124" rel="#L124" style="color: rgb(102, 102, 102); text-decoration: none;"> 124</a>
<a target=_blank id="L125" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L125" rel="#L125" style="color: rgb(102, 102, 102); text-decoration: none;"> 125</a>
<a target=_blank id="L126" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L126" rel="#L126" style="color: rgb(102, 102, 102); text-decoration: none;"> 126</a>
<a target=_blank id="L127" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L127" rel="#L127" style="color: rgb(102, 102, 102); text-decoration: none;"> 127</a>
<a target=_blank id="L128" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L128" rel="#L128" style="color: rgb(102, 102, 102); text-decoration: none;"> 128</a>
<a target=_blank id="L129" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L129" rel="#L129" style="color: rgb(102, 102, 102); text-decoration: none;"> 129</a>
<a target=_blank id="L130" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L130" rel="#L130" style="color: rgb(102, 102, 102); text-decoration: none;"> 130</a>
<a target=_blank id="L131" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L131" rel="#L131" style="color: rgb(102, 102, 102); text-decoration: none;"> 131</a>
<a target=_blank id="L132" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L132" rel="#L132" style="color: rgb(102, 102, 102); text-decoration: none;"> 132</a>
<a target=_blank id="L133" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L133" rel="#L133" style="color: rgb(102, 102, 102); text-decoration: none;"> 133</a>
<a target=_blank id="L134" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L134" rel="#L134" style="color: rgb(102, 102, 102); text-decoration: none;"> 134</a>
<a target=_blank id="L135" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L135" rel="#L135" style="color: rgb(102, 102, 102); text-decoration: none;"> 135</a>
<a target=_blank id="L136" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L136" rel="#L136" style="color: rgb(102, 102, 102); text-decoration: none;"> 136</a>
<a target=_blank id="L137" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L137" rel="#L137" style="color: rgb(102, 102, 102); text-decoration: none;"> 137</a>
<a target=_blank id="L138" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L138" rel="#L138" style="color: rgb(102, 102, 102); text-decoration: none;"> 138</a>
<a target=_blank id="L139" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L139" rel="#L139" style="color: rgb(102, 102, 102); text-decoration: none;"> 139</a>
<a target=_blank id="L140" href="http://blog.csdn.net/g_brightboy/article/details/14229139#L140" rel="#L140" style="color: rgb(102, 102, 102); text-decoration: none;"> 140</a>
"打開語法高亮
syntax on
"使用配色方案
colorscheme desert
"打開文件類型檢測功能
filetype on
"不同文件類型採用不同縮進
filetype indent on
"允許使用插件
filetype plugin on
filetype plugin indent on
"關閉vi模式
set nocp
"與windows共享剪貼板
set clipboard+=unnamed
"取消VI兼容,VI鍵盤模式不易用
set nocompatible
"顯示行號, 或set number
set nu
"歷史命令保存行數
set history=100
"當文件被外部改變時自動讀取
set autoread
"取消自動備份及產生swp文件
set nobackup
set nowb
set noswapfile
"允許使用鼠標點擊定位
set mouse=a
"允許區域選擇
set selection=exclusive
set selectmode=mouse,key
"高亮光標所在行
set cursorline
"取消光標閃爍
set novisualbell
"總是顯示狀態行
set laststatus=2
"狀態欄顯示當前執行的命令
set showcmd
"標尺功能,顯示當前光標所在行列號
set ruler
"設置命令行高度爲3
set cmdheight=3
"粘貼時保持格式
set paste
"高亮顯示匹配的括號
set showmatch
"在搜索的時候忽略大小寫
set ignorecase
"高亮被搜索的句子
set hlsearch
"在搜索時,輸入的詞句的逐字符高亮(類似firefox的搜索)
set incsearch
"繼承前一行的縮進方式,特別適用於多行註釋
set autoindent
"爲C程序提供自動縮進
set smartindent
"使用C樣式的縮進
set cindent
"製表符爲4
set tabstop=4
"統一縮進爲4
set softtabstop=4
set shiftwidth=4
"允許使用退格鍵,或set backspace=2
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"取消換行
set nowrap
"啓動的時候不顯示那個援助索馬里兒童的提示
set shortmess=atI
"在被分割的窗口間顯示空白,便於閱讀
set fillchars=vert:\ ,stl:\ ,stlnc:\
"光標移動到buffer的頂部和底部時保持3行距離, 或set so=3
set scrolloff=3
"設定默認解碼
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
"設定字體
set guifont=Courier_New:h11:cANSI
set guifontwide=新宋體:h11:cGB2312
"設定編碼
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"自動補全
filetype plugin indent on
set completeopt=longest,menu
"自動補全命令時候使用菜單式匹配列表
set wildmenu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet
 來自CODE的代碼片
vimrc.vim

【vim的語法高亮/配色方案】

vim的配色分兩部分:編輯環境配色和文本區域配色
1) vim編輯環境配色:比如Vim編輯區的前景背景色、狀態欄顏色、錯誤提示顏色、查找、光標、圈選區、行號、摺疊等的顏色
這裏列出幾個配色組名及其含義(全部的詳細信息查看幫助文件 :help hi 查找 "highlight-group" 即可):

[plain] view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. Cursor        光標下的字符顏色    
  2. CursorLine    光標所在行顏色    
  3. ErrorMsg      命令行出現的錯誤信息提示    
  4. IncSearcg     被搜索字符的顏色    
  5. Normal        普通字符    
  6. Pmenu         彈出的提示條目顏色    
  7. PmenuSel      彈出的提示條目中被選中條目的顏色    
  8. SpellBad      拼寫錯誤字符顏色    
  9. Visual        可視化模式下選中字符的顏色    
  10. Menu          菜單欄的顏色字體    
  11. Scrollbar     滾動條的顏色   

2) 文本區域配色:可編輯的文本區域的字符配色(詳細信息請執行 :help hi搜索 "*comment")
由於配色種類較多,vim默認分了幾大類(幫助信息中帶*的):

[plain] view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. *Comment        註釋  
  2. *Constant       常量  
  3. *statement      常用關鍵字標示符  
  4. *PrePoc         預處理符號  
  5. *Type           數據類型  


下面是較爲詳細的組別:

[plain] view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. String          字符串常量: "string abc\n"  
  2. Character       單個字符常量: 'c', '\n'  
  3. Number          數字常量: 234, 0xff  
  4. Boolean         布爾常量: TRUE, false  
  5. Function        函數名  
  6. Conditional     條件關鍵字: if, then, else, endif, switch, etc.  
  7. Repeat          循環關鍵字: for, do, while, etc.  
  8. Operator        操作符: "sizeof", "+", "*", etc.  
  9. Exception       異常關鍵字: try, catch, throw  

這樣便可以更爲詳細的爲每一個組別進行配色。

查看當前的vim配色情況
:hi/highlight

另外,文本區域的配色可以關閉,但環境配色不能,通常vim給定的默認可選配色方案中同時包含了以上兩個方面。
下面就一條具體的配色命令(對數據類型配色)解釋每個字段的含義:

hi Type cterm=none ctermbg=White ctermfg=Green guibg=Gray guifg=Red

hi: highlight的縮寫,配色命令
Type: 配色組名,可以自定義(修改$VIMRUNTIME/syntax/下對應的文件可改變不同語言的高亮方案)其內容 
cterm,ctermbg,ctermfg,guibg,guifg: 代表了不同顯示環境
White,Green: 表示顏色(也可以用數字或者類似與html的16進制顏色表示方法)

顯示環境有三種:黑白終端,彩色終端,圖形界面,三種環境下參數名稱如下:

[plain] view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. term        attributes in a B&W terminal  
  2. cterm       attributes in a color terminal  
  3. ctermfg     foreground color in a color terminal  
  4. ctermbg     background color in a color terminal  
  5. gui         attributes in the GUI  
  6. guifg       foreground color in the GUI  
  7. guibg       background color in the GUI  

 

其中term僅有黑白兩色,cterm下顏色較爲單一,GUI模式顏色豐富

若要僅修改某種語言(c、java、pascal)的配色,則在配色組名前加語言名稱即可,比如對c/c++語言的數據類型單獨配色:
hi cType ctermfg=Blue

若是修改java/pascal的數據類型,則相應的將cType替換爲javaType/pascalType即可。

對於文本區域的語法高亮(即配色),我們可根據需求特殊化定製,比如自定義組: myUniqueWord, mySymbol,使用syn/syntax命令
syn keyword myUniqueWord gang Gang swagger
syn match mySymbol "[,.;(){}[]]" (可使用正則表達式)


vim目前7.4版本給出的可直接使用(colorscheme命令加於.vimrc中即可)的配色方案位於目錄:
/usr/local/share/vim/vim74/colors,比如使用desert.vim中的配色,則於.vimrc中添加一行
colorscheme desert
即可

網友提供的配色方案列表(帶效果圖),可參考:
http://vimcolorschemetest.googlecode.com/svn/html/index-c.html
http://www.oschina.net/news/32306/10-vim-color-schemes-you-need-to-own

:hi/highlight
命令,可查看當前vim的顏色配置

:help hi/highlight
顯示幫助文件(syntax.txt,可訪問官方在線版
http://vimdoc.sourceforge.net/htmldoc/syntax.html)內容,介紹了顏色配置腳本中關鍵字的含義和使用方法

相同配色vim腳本在不同的終端下可能顯示不太一致,這是由終端下顏色設置不一致導致的,屬正常情況。

【vim的代碼補全、結構化視圖】(基於autocomplpop + omnicppcomplete + ctags + taglist + cscope + NERDtree)

先一句話介紹每個插件的用途:
--> ctags: 爲源碼的變量/對象、結構體/類、函數/接口、宏等產生索引,以便快速查找和定位
 - Official site  
http://ctags.sourceforge.net/
 - VIM online  
http://www.vim.org/scripts/script.php?script_id=610

--> taglist:提供源碼的結構化瀏覽功能
 - Official site  
http://vim-taglist.sourceforge.net/
 - VIM online  http://www.vim.org/scripts/script.php?script_id=273

--> AutoComplPop:代碼補全提示自動彈出
 - VIM online  
http://www.vim.org/scripts/script.php?script_id=1879

--> OmniCppComplete:基於ctags的索引文件提供全面的c++(類成員、繼承、this指針、.->訪問符等)的代碼補全功能
 - VIM online  
http://www.vim.org/scripts/script.php?script_id=1520

--> cscope:對代碼產生索引數據庫,提供對象接口字符串的查找,並用列表顯示(:cw - quickfix)
 - Official site  
http://cscope.sourceforge.net/
 - VIM online  http://www.vim.org/scripts/script.php?script_id=4082 

--> NERDtree:以樹形結構顯示文件系統的目錄(同windows的資源管理器),並可以在目錄間切換
- VIM online http://www.vim.org/scripts/script.php?script_id=1658

vim支持的幾乎所有plugin&&utility都在這裏可以下載到(主要以vim腳本的形式)
http://www.vim.org/scripts/index.php

下面逐一介紹各個插件的安裝和使用方法
1) ctags
2) taglist
3) AutoComplPop
4) OmniCppComplete
5) cscope

6) NERDtree
(待續)

由於後續各個插件的介紹篇幅較長,單獨形成博文,請參考:

ctags 的安裝和使用方法,請猛擊:http://blog.csdn.net/g_brightboy/article/details/16830395

taglist的安裝和使用方法,請猛擊:http://blog.csdn.net/g_brightboy/article/details/16843899

AutoComplPop和OmniCppComplete的安裝和使用方法,請用力敲鼠標左鍵:http://blog.csdn.net/g_brightboy/article/details/19498983

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章