歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Vim 用戶手冊閱讀導覽

Vim 用戶手冊閱讀導覽

日期:2017/2/28 15:53:18   编辑:Linux教程

學習Vim 時遇到了困難,所以想做點工作來減低一下門檻 ...

先一個例子來說明文檔的表示結構和方法 ...
#vim
:help e117
內容如下:

  1. :cal :call E107 E117
  2. :[range]cal[l] {name}([arguments])
  3. Call a function. The name of the function and its arguments
  4. are as specified with :function. Up to 20 arguments can be
  5. used. The returned value is discarded.
  6. Without a range and for functions that accept a range, the
  7. function is called once. When a range is given the cursor is
  8. positioned at the start of the first line before executing the
  9. function.
  10. When a range is given and the function doesn't handle it
  11. itself, the function is executed for each line in the range,
  12. with the cursor in the first column of that line. The cursor
  13. is left at the last line (possibly moved by the last function
  14. call). The arguments are re-evaluated for each line. Thus
  15. this works:
  16. function-range-example >
  17. :function Mynumber(arg)
  18. : echo line(".") . " " . a:arg
  19. :endfunction
  20. :1,5call Mynumber(getline("."))
  21. <
  22. The "a:firstline" and "a:lastline" are defined anyway, they
  23. can be used to do something different at the start or end of
  24. the range.
  25. Example of a function that handles the range itself: >
  26. :function Cont() range
  27. : execute (a:firstline + 1) . "," . a:lastline . 's/^/\t\\ '
  28. :endfunction
  29. :4,8call Cont()
  30. <
  31. This function inserts the continuation character "\" in front
  32. of all the lines in the range, except the first one.
  33. When the function returns a composite value it can be further
  34. dereferenced, but the range will not be used then. Example: >
  35. :4,8call GetDict().method()
  36. < Here GetDict() gets the range but method() does not.
每一個 >(包括前面的block(塊))<(包括後面的block(塊)),包括><中間的block(塊),構成一個完整的模塊。

命令詳解:

:代表 命令模式
[range]代表范圍,[]表示option(可選)。
cal 表示調用,固定且必備。
{name}代表所要調用的函數名,name 是一個非固定值且必備。

([arguments]) 表示參數 左右括號是必須的,[arguments] 是非固定的並且是可選的。


接下來開始對學習進行導航 :

在命令模式下:

:help user-manual

打開用戶手冊,這或者vim最好的教程吧,嘻嘻 ,把光標 hjkl 移動到usr_02.txt 等高亮標簽上面去,按著 <C-]>是跳轉過去,<C-o>是跳轉回來(按鍵為Ctrl + o),<C-t>是返回。

:help usr_02.txt 是一個quicktutor


接下來是如何產看現有的映射情況:

:map 是查看映射情況

:nmap 是查看normal模式下的映射情況

:vmap 是查看visual模式下的映射情況

:imap 是查看insert 模式下的映射情況
:set 則可以看到一些現有的設置,例如runtimepath


說起來英文真是半桶水,有些地方看來一知半解,所以還是要借助一下中文翻譯。

http://vimcdoc.sourceforge.net/ (下載中文文檔)

#wget http://prdownloads.sourceforge.net/vimcdoc/vimcdoc-1.8.0.tar.gz?download

#tar zxvf vimcdoc-1.8.0.tar.gz

此時注意要用普通用戶身份運行安裝腳本.它會把文檔拷貝到$HOME/.vim 下。

#cd vimcdoc-1.8.0

#./vimcdoc.sh -i

這樣就ok 了 ,接下來就可以使用 :set helplang=en 和 :set helplang=cn進行切換了 。


而在線的中文用戶手冊可以在這裡,可以查看手冊的目錄樹,還有檢索:
http://vimcdoc.sourceforge.net/doc/help.html
通過google 搜索來進行檢索 例如 : “烏干達 site:vimcdoc.sourceforge.net”


而學習了部分基本操作之後,就需要進行配置和鼓搗插件了,這裡有兩個小技巧分享一下 .


1." 配置文件.vimrc更改後自動重新載入使設置生效,而不需要重新啟動vim
autocmd! bufwritepost .vimrc source ~/.vimrc


2.同時用插件管理系統 vbundle , 來對插件進行更新和安裝

https://github.com/gmarik/vundle

配置方法也在這個頁面裡面有。

Copyright © Linux教程網 All Rights Reserved