詳細Vim快捷鍵大全git
項目地址: github.com/spf13/spf13…github
The easiest way to install spf13-vim is to use our automatic installer by simply copying and pasting the following line into a terminal. This will install spf13-vim and backup your existing vim configuration. If you are upgrading from a prior version (before 3.0) this is also the recommended installation.shell
Requires Git 1.7+ and Vim 7.3+vim
curl https://j.mp/spf13-vim3 -L > spf13-vim.sh && sh spf13-vim.sh
複製代碼
If you have a bash-compatible shell you can run the script directly:windows
sh <(curl https://j.mp/spf13-vim3 -L)
複製代碼
此過程會比較長,包括插件的下載還有安裝,這個過程將近1個多小時瀏覽器
On Windows and *nix Git and Curl are required. Also, if you haven't done so already, you'll need to install Vim. The quickest option to install all three dependencies (Git, Curl, Vim and spf13-vim) is via Chocolatey NuGet. After installing Chocolatey, execute the following commands on the command prompt:ruby
Install with cmd.exe(run as admin mode)bash
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
複製代碼
C:\> choco install spf13-vim
複製代碼
一直Y,整個過程大概2h左右markdown
Vundle is an excellent system built on the same principles as Pathogen, but with an integrated plugin management system that is Git and Github aware.app
spf13-vim uses the Vundle plugin management system to have a well organized vim directory (Similar to mac's app folders). Vundle also ensures that the latest versions of your plugins are installed and makes it easy to keep them up to date.
NERDTree is a file explorer plugin that provides "project drawer" functionality to your vim editing. You can learn more about it with :help NERDTree or checkout my post on NERDTree.
Use Ctrl+e
to toggle NERDTree
Ctrlp replaces the Command-T plugin with a 100% viml plugin. It provides an intuitive and fast mechanism to load files from the file system (with regex and fuzzy find), from open buffers, and from recently used files.
Use Ctrl+p
to toggle Ctrlp
NeoComplCache is an amazing autocomplete plugin with additional support for snippets. It can complete simulatiously from the dictionary, buffer, omnicomplete and snippets. This is the one true plugin that brings Vim autocomplete on par with the best editors.
Use Ctrl+n
to toggle neocomplcache
spf13-vim includes the Tagbar plugin. This plugin requires exuberant-ctags and will automatically generate tags for your open files. It also provides a panel to navigate easily via tags
Use ,tt
to toggle neocomplcache
在Windows端,若是想切換到別的盤符進行操做的話,使用
:NERDTree D:\\
進行目錄的跳轉
在使用previewMarkdown的時候出現了 Preview: To preview markdown format you need to install bluecloth gem
解決方法:
sudo gem install redcarpet
sudo gem install bluecloth
can't find header files for ruby at /usr/lib/ruby/include/ruby.h
解決方法:sudo apt-get install ruby-dev
用法:
1.生成標籤文件(cmd到項目的目錄中執行)
在當前目錄下(運行$提示符後面的命令):
$ctags -R .
-R表示recursive,遞歸,爲當前目錄及其子目錄中的c文件生成標籤文件。最後一個.表示在當前目錄。
運行完當前目錄會多一個文件tags,就是c標籤的索引文件。
2.跳轉
1)用vim打開一個已經建過標籤的c文件
2)ctrl+] 找到光標所在位置的標籤訂義的地方
3)ctrl+t 回到跳轉以前的標籤處
3.窗口顯示方法
命令Tagbar toggle打開相應的方法窗口顯示
注意:此時運行vim,必須在"tags"文件所在的目錄下運行。不然,運行它會找不到"tags"文件,而須要在vim中用":set tags="命令設定"tags"文件的路徑。對於一個稍微大點的項目,你可能在任何一個目錄下打開vim,然而在每一個目錄下都生成一個tags文件並不 是個好主意,那麼如何解決呢?方法是在.vimrc中增長一行:
set tags=tags;/
這是告訴vim在當前目錄找不到tags文件時請到上層目錄查找。
複製代碼
Ctrl+w+w
關閉當前窗口。
Ctrl+W c
關閉當前窗口,若是隻剩最後一個了,則退出Vim。
Ctrl+W q
複製代碼
:buffers 列表 :bn下一個 :bp 上一個 :b17
set: nohlseach
複製代碼
vim進了多行編輯模式:<ESC>以後按CTRL+V進入visual block模式(列編輯)。光標移到某行行首,進入visual block模式,上下鍵選擇行,按I(i的大寫字母),輸入##,而後按<ESC>鍵,這樣就在多行行首添加##了。也能夠在多行的固定位置添加固定字符。
若是要刪除這些##,進入visual block模式,選中這些##,按d便可。
複製代碼
按鍵 | 功能 |
---|---|
? | 顯示鍵盤映射 |
o | 打開文件 |
O | 打開文件關閉QuickFix窗口 |
go | 預覽文件,但焦點留在ack搜索結果上 |
t | 在新標籤頁打開文件 |
T | 在新標籤頁打開但不切換到那個標籤頁 |
h | 分屏打開 |
H | 分屏打開,但焦點停留在ack搜索結果上 |
v | 豎直分屏打開 |
gv | 豎直分屏打開,但焦點停留在ack搜索結果上 |
q | 關閉QuickFix窗口 |
在Windows下安裝它們可使用Chocolatey,安裝方法以下:首先以管理員權限打開cmd窗口,而後運行下列命令,首先以管理員權限打開cmd窗口(管理員那個終端纔有效),而後運行下列命令
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
複製代碼
安裝完了以後
choco install ack
複製代碼
brew install ack
複製代碼
若是出現亂碼
'perl' 不是內部或外部命令,也不是可運行的程序
複製代碼
下載安裝ActivePerl,配置環境變量便可解決此問題。 下載地址
該配色使用的是gruvbox
若是想更換成此主題
"gruvbox主題"
Plugin 'morhetz/gruvbox'
set bg=dark
colorscheme gruvbox
複製代碼
而後全局搜索let g:airline_theme
,改爲以下顏色防止顏色不協調
let g:airline_theme = 'dark'
複製代碼
終端運行 PluginInstall
完成以後,重啓就能夠了
啓動Vim的時候Ctrl+o
便可
使用標記能夠快速移動。到達標記後,能夠用Ctrl+o返回原來的位置。 Ctrl+o和Ctrl+i 很像瀏覽器上的 後退 和 前進 。
m{a-z}: 標記光標所在位置,局部標記,只用於當前文件。
m{A-Z}: 標記光標所在位置,全局標記。標記以後,退出Vim, 從新啓動,標記仍然有效。
`{a-z}: 移動到標記位置。
‘{a-z}: 移動到標記行的行首。
`{0-9}:回到上[2-10]次關閉vim時最後離開的位置。
`: 移動到上次編輯的位置。"也能夠,不過`精確到列,而"精確到行 。若是想跳轉到更老的位置,能夠按C-o,跳轉到更新的位置用C-i。
`」: 移動到上次離開的地方。
`.: 移動到最後改動的地方。
:marks 顯示全部標記。
:delmarks a b – 刪除標記a和b。
:delmarks a-c – 刪除標記a、b和c。
:delmarks a c-f – 刪除標記a、c、d、e、f。
:delmarks! – 刪除當前緩衝區的全部標記。
:help mark-motions 查看更多關於mark的知識。
- 首先,查看vim版本是否支持clipboard
vim --version | grep "clipboard"
複製代碼
clipboard前面有一個小小的減號,說明不支持。
sudo apt-get install vim-gnome
複製代碼
安裝完成後再次執行:
vim --version | grep "clipboard"
複製代碼
發現已經支持clipboard
那麼咱們的目的是要複製到系統剪切板則須要選中內容後輸入命令:"+y
粘貼到特定的寄存器也是同理。例如"+p將系統剪切板的內容拷貝到vim中(非編輯模式下)。
配置以下:
let g:EasyMotion_smartcase = 1
"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
map <Leader><leader>h <Plug>(easymotion-linebackward)
map <Leader><Leader>j <Plug>(easymotion-j)
map <Leader><Leader>k <Plug>(easymotion-k)
map <Leader><leader>l <Plug>(easymotion-lineforward)
" 重複上一次操做, 相似repeat插件, 很強大 map <Leader><leader>. <Plug>(easymotion-repeat) 複製代碼
1.還能夠f和t, 不過建議簡單化, 一個w/b走天下.
2.若是你不常用s, 能夠將s改鍵, nmap s (easymotion-s), 這樣你只須要輸入s就能夠進行搜索快速跳轉(強迫症表示不能忍....) 具體作法見官方文檔
3.默認做爲這個插件的快捷鍵其實挺好的, 貌似沒有其餘插件會致使衝突, 還能夠配置一整套, 強迫症很滿意
4.能夠配置2/n個字符的搜索跳轉, 更精準, 按需自取(我的以爲太複雜了不必) 文檔和文檔
5.這個插件專心作好跳轉就好, 不必把搜索的活給作了
鼠標在各個窗口間循環移動: ctrl+w+(小寫的 hjkl), "非線性"的跳轉的: ctrl_w+t(top : 左上角, +b: bottom, 右下角), p: preview: 上一個子窗口. set mouse=a 全部all 的狀態下均可以使用 鼠標..
窗口自己的位值的移動: ctrl_w + r: 窗口自己, 不是鼠標指針順時針 (向下, 向右 移動), R : 則是逆時針反方向(向上, 向左)移動. ctrl_w+x: 左右上下對應位置的窗口 對調. 要注意窗口必須是 對應的, 若是不對應將沒法對換, 好比左邊一個大窗口, 右邊有兩個小的 子窗口, 則左右不能互換.
窗口自己 的位置移動, 並且大小也發生"最大化"變化 Ctrl_w+ HJKL( 注意是大寫的字母 H, J, K, L , 表示要按shift才能實現的)... 要注意, 能夠經過 windows 窗口 "貼邊" 最大化來理解, H和 L 就是 向左或向右 最大化貼邊 顯示; 而 JK 則是 向上 或 向下 貼邊 最大化顯示. 最大化後 就不能 再次操做復原窗口了, 其實也沒有必要
調整窗口的水平/垂直尺寸? 用ctrl+ w 結合 >, <調整水平尺寸, 用+ - 調整垂直尺寸, 這個是微調. 也能夠用純粹的命令用 :resize +/- n, 或者 vertical resize +/- n (支持命令簡寫, 可是要可以使命令被惟一肯定才行. 一般要用5,10,15, 20的大小間隔來調...過小了沒有意義)
除了這些調整/ 遍歷鼠標的方法, 還有一個關閉子窗口的問題. 關閉的方式, 除了命令外, 還有窗口關閉 的方式: 用ctrl+w + q(quit), c(close), o(other)等.
使用:
一、 \cc 註釋當前行和選中行
二、 \cn 沒有發現和\cc有區別
三、 \c<空格> 若是被選區域有部分被註釋,則對被選區域執行取消註釋操做,其它狀況執行反轉註釋操做
四、 \cm 對被選區域用一對註釋符進行註釋,前面的註釋對每一行都會添加註釋
五、 \ci 執行反轉註釋操做,選中區域註釋部分取消註釋,非註釋部分添加註釋
六、 \cs 添加性感的註釋,代碼開頭介紹部分一般使用該註釋
七、 \cy 添加註釋,並複製被添加註釋的部分
八、 \c$ 註釋當前光標到改行結尾的內容
九、 \cA 跳轉到該行結尾添加註釋,並進入編輯模式
十、\ca 轉換註釋的方式,好比: /**/和//
十一、\cl \cb 左對齊和左右對其,左右對其主要針對/**/
十二、\cu 取消註釋
複製代碼
方案一:
brew install vim --with-lua
方案二:
brew uninstall vim
brew install luajit
brew install vim --with-luajit
複製代碼
更多文章請轉到github.com/itgoyo/500D…
歡迎關注本人的Github:itgoyo