vim ctrlp_使用Ctrlp和Ctag使Vim更智能

vim ctrlp

by _haochuan

通過_haochuan

使用Ctrlp和Ctag使Vim更智能 (Make Your Vim Smarter Using Ctrlp and Ctags)

I absolutely love Vim, and I use Vim for all my coding and writing from year to year. Although more are more people, especially for those are working with JavaScript, prefer modern code editors such as Sublime Text or VSCode, I’d rather spend a little time trying to make my toy more intelligent.

我絕對喜歡Vim,并且我每年都使用Vim進行所有編碼和寫作。 盡管有更多的人,特別是對于那些使用JavaScript的人,更喜歡諸如Sublime Text或VSCode之類的現代代碼編輯器,但我還是愿意花一點時間來使我的玩具更智能。

CtrlP (CtrlP)

If you are a Sublime Text, Atom, or VSCode guy, you must use ctrl + p thousands of times to improve productivity. Well, don’t be jealous if you are a Vim guy because this fancy Vim plugin CtrlP will give you all you need.Check this official doc for installation and setup.

如果您是Sublime Text,Atom或VSCode方面的人,則必須使用ctrl + p數千次才能提高生產力。 好吧,如果您是Vim家伙,請不要嫉妒,因為這個花哨的Vim插件CtrlP會為您提供所需的一切。請查看此官方文檔進行安裝和設置。

標簽 (Ctags)

Ctags is a tool that will sift through your code, indexing methods, classes, variables, and other identifiers, storing the index in a tags file. The tags file contains a single tag per line. Depending on command line arguments and the language ctags is run against, a lot of information can be obtained from this index.

Ctags是一種工具,可用于篩選代碼,索引方法,類,變量和其他標識符,并將索引存儲在標簽文件中。 標簽文件每行包含一個標簽。 根據命令行參數和使用的語言ctags,可以從該索引中獲取很多信息。

Ctags currently supports 41 programming languages, and it’s relatively easy to add definitions for more.

Ctags當前支持41種編程語言 ,并且添加更多的定義相對容易。

Ctags makes it much easier to navigate a larger project, particularly if the code you’re working with is unfamiliar. If you’re unsure of what a method does or how it’s supposed to be called, you can jump straight to its definition. If you’re in the downward spiral of a 500+ line Perl script and want to know where a variable was defined three hours ago, you can jump right back to it. And afterward, you can jump right back to where you were working.

Ctags使導航更大的項目變得容易得多,尤其是在您不熟悉所使用的代碼的情況下。 如果不確定方法的作用或方法的調用方式,可以直接轉到其定義。 如果您處于Perl腳本超過500行的螺旋式下降狀態,并且想知道三個小時前在哪里定義了變量,則可以直接跳回到該變量。 然后,您可以跳回到工作地點。

You can install Ctags using Homebrew in OSX:

您可以在OSX中使用Homebrew安裝Ctags:

brew install ctags

Please note that OS X comes with a Ctags executable, but it’s not exuberant-Ctags and is missing most of the useful features. If you see an error like Invalid Parameter when you run ctags, it means that the system is not using the one you installed with Homebrew. To solve this:

請注意,OS X帶有Ctags可執行文件,但它不是旺盛的Ctags,并且缺少大多數有用的功能。 如果在運行ctags時看到諸如Invalid Parameter類的錯誤,則表明系統未使用您通過Homebrew安裝的系統。 要解決這個問題:

$ alias ctags="`brew --prefix`/bin/ctags"

When you’re sitting in the directory you want to index, just run:

當您坐在要索引的目錄中時,只需運行:

ctags -R.

Ctags will walk through the directory recursively, tagging all source files it encounters. For very large projects, this might take a while, but normally it’s pretty fast.

Ctags將遞歸遍歷該目錄,標記它遇到的所有源文件。 對于非常大的項目,這可能需要一段時間,但通常速度很快。

You may also need some extra config for Ctags, below is the ~/.ctags I'm using:

您可能還需要對Ctags進行一些額外的配置,以下是我正在使用的~/.ctags

--langmap=javascript:.js.es6.es.jsx--javascript-kinds=-c-f-m-p-v
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\2/A,Array,Arrays/
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Z][A-Za-z0-9_$]+)[ \t]*=[ \t]*function/\2/C,Class,Classes/--regex-javascript=/^[ \t]*class[ \t]+([A-Za-z0-9_$]+)/\1/C,Class,Classes/
--regex-javascript=/^[ \t]*export[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\3/E,Export,Exports/--regex-javascript=/^[ \t]*export[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\5/E,export,Exports/--regex-javascript=/^[ \t]*export[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\7/E,Export,Exports/--regex-javascript=/^[ \t]*export[ \t]?(var|let|const)[ \t]+([A_Za-z0-9_$]+)/\2/E,Export,Exports/--regex-javascript=/^[ \t]*export[ \t]?(var|let|const)[ \t]+([A_Za-z0-9_$]+)[ \t]*[^,]+,[ \t]*([A_Za-z0-9_$]+)/\3/E,Export,Exports/--regex-javascript=/^[ \t]*export[ \t]?(var|let|const)[ \t]+([A_Za-z0-9_$]+)[ \t]*[^,]+,[ \t]*([A_Za-z0-9_$]+)[ \t]*[^,]+,[ \t]*([A_Za-z0-9_$]+)/\4/E,Export,Exports/
--regex-javascript=/^[ \t]*function[ \t]*([A-Za-z0-9_$]+)[ \t\(]/\1/F,Function,Functions/--regex-javascript=/^[ \t]*[\(]function[ \t]*([A-Za-z0-9_$]+)[ \t\(]/\1/F,Function,Functions/--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([a-z][A-Za-z0-9_$]+)[ \t]*=[ \t]*function[^\*][^\*]/\2/F,Function,Functions/--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([a-z][A-Za-z0-9_$]+)[ \t]*=[ \t]*\([^\*]/\2/F,Function,Functions/
--regex-javascript=/^[ \t]*function[ \t]*\*[ \t]*([A-Za-z0-9_$]+)/\1/G,Generator,Generators/--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([a-z][A-Za-z0-9_$]+)[ \t]*=[ \t]*function([ \t]*\*)/\2/G,Generator,Genrators/--regex-javascript=/^[ \t]*(\*[ \t])([A-Za-z0-9_$]+)[ \t]*\(.*\)[ \t]*{/\2/G,Generator,Generators/
--regex-javascript=/^[ \t]*import[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\3/I,Import,Imports/--regex-javascript=/^[ \t]*import[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\5/I,Import,Imports/--regex-javascript=/^[ \t]*import[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\7/I,Import,Imports/
--regex-javascript=/^[ \t]*this\.([A-Za-z0-9_$]+)[ \t]*=.*{$/\1/M,Method,Methods/--regex-javascript=/^[ \t]*([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*[\(]*function[ \t]*\(/\1/M,Method,Methods/--regex-javascript=/^[ \t]*static[ \t]+([A-Za-z0-9_$]+)[ \t]*\(/\1/M,Method,Methods/--regex-javascript=/^[ \t]*([A-Za-z0-9_$]+)\(.*\)[ \t]*{/\1/M,Method,Methods/
--regex-javascript=/^[ \t]*(this\.)*([A-Za-z0-9_$]+)[ \t]*[:=].*[,;]*[^{]$/\2/P,Property,Properties/
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Za-z0-9_$]+)[ \t]*=[ \t]*{/\2/O,Object,Objects/
--regex-javascript=/\/\/[ \t]*(FIXME|TODO|BUG|NOBUG|\?\?\?|\!\!\!|HACK|XXX)[ \t]*\:*(.*)/\1/T,Tag,Tags/
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^\[{]*;$/\2/V,Variable,Variables/
--exclude=min--exclude=vendor--exclude=\*.min.\*--exclude=\*.map--exclude=\*.swp--exclude=\*.bak--exclude=tags--exclude=node_modules--exclude=bower_components--exclude=test--exclude=__test__--exclude=build--exclude=dist--exclude=*.bundle.*

Here is how it looks like going to function definition:

這是去函數定義的樣子:

Also you can use Ctrlp to search for tags instead of files. To do this, first you need to map a shortcut in your .vimrc:

您也可以使用Ctrlp搜索標簽而不是文件。 為此,首先需要在.vimrc映射一個快捷方式:

nnoremap <leader>. :CtrlPTag<cr>

Here is how it works:

下面是它的工作原理:

Hope it helps :)

希望能幫助到你 :)

I write code for audio and web, and play guitar on YouTube. If you want to see more stuff from me or know more about me, you can always find me in:

我編寫音頻和網絡代碼,并在YouTube上彈吉他。 如果您想從我這里了解更多信息或對我有更多了解,可以隨時在以下位置找到我:

Website:https://haochuan.io/

網址: https : //haochuan.io/

GitHub:https://github.com/haochuan

GitHub: https : //github.com/haochuan

Medium:https://medium.com/@haochuan

媒介: https : //medium.com/@haochuan

YouTube: https://www.youtube.com/channel/UCNESazgvF_NtDAOJrJMNw0g

YouTube: https : //www.youtube.com/channel/UCNESazgvF_NtDAOJrJMNw0g

翻譯自: https://www.freecodecamp.org/news/make-your-vim-smarter-using-ctrlp-and-ctags-846fc12178a4/

vim ctrlp

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/394821.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/394821.shtml
英文地址,請注明出處:http://en.pswp.cn/news/394821.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

linux系統可以無顯卡運行嗎,Linux操作系統無顯卡安裝方式

顯卡安裝方法&#xff1a;操作步驟&#xff1a;1、SBC上裝上顯卡&#xff0c;并啟動安裝程序2、安裝linux系統并選擇相應的安裝包(選擇lilo啟動加載程序)如果安裝時以GRUB方式加載的&#xff0c;需要在Grub.conf中將有關圖形的語句屏蔽掉。#splashimage(hd0,0)/grub/splash.xpm…

軟件工程專業實習可以做什么_想要獲得軟件工程實習機會? 這里有一些想法可以幫助您...

軟件工程專業實習可以做什么by Tatiana Doyle塔蒂亞娜道爾(Tatiana Doyle) 想要獲得軟件工程實習機會&#xff1f; 這里有一些想法可以幫助您。 (Looking to land a software engineering internship? Here are some thoughts to help you.) A note: this post is simply mea…

ubuntu 簡單配置samba

關鍵字: ubuntu samba今天在家&#xff0c;閑著沒事&#xff0c;就想學習一下samba 來實現windows xp 訪問ubuntu 的文件夾&#xff08;家里有兩臺pc&#xff09;&#xff0c;google了很多文章&#xff0c;但是很多都沒有用&#xff0c;不過鳥哥的文章有很清楚的介紹&#xff0…

python3.8文檔_python 3.8的新功能

演示和工具 添加了一個基準腳本&#xff0c;用于計時訪問變量的各種方式&#xff1a; Tools/scripts/var_access_benchmark.py . &#xff08;由Raymond Hettinger在 bpo-35884 &#xff09; 以下是自Python3.3以來性能改進的摘要&#xff1a; Python version 3.3 3.4 3.5 3.6 …

mysql數據庫備份及還原

一、Mysql數據庫備份指令格式&#xff1a; mysqldump -h主機名 -P端口 -u用戶名 -p密碼 (–database) 數據庫名 > 文件名.sql 注&#xff1a;直接cmd執行該指令即可&#xff0c;不需要先mysql -u root -p鏈接數據庫 1、備份MySQL數據庫的命令mysqldump -hhostname -uuserna…

linux隱藏apache信息,Apache防盜鏈和隱藏版本信息-linux-centos運維

有需要服務器方面的需求和咨詢&#xff0c;可以聯系博主 QQ 7271895一、防盜鏈二、隱藏版本信息實驗要求&#xff1a;三臺虛擬機分別是&#xff1a;linux和兩臺windows虛擬機&#xff0c;linux虛擬機為服務器&#xff0c;Windows7-1為客戶端&#xff0c;Windows7-2為盜鏈端。實…

查看oracle當前的連接數

SQL> select count(*) from v$session #當前的連接數SQL> Select count(*) from v$session where statusACTIVE #并發連接數SQL> select value from v$parameter where name processes --數據庫允許的最大連接數SQL> show parameter processes #最大連接 SQL> …

led顯示屏控制卡接線圖解_Led顯示屏出現花屏是什么原因

Led顯示屏已經成為現在人們推廣的一種形式了&#xff0c;很多地方都是離不開led顯示屏的使用的。由于Led顯示屏的五彩絢爛&#xff0c;也更加吸引人們的眼球。不過在使用過程中&#xff0c;也會遇到Led顯示屏花屏的情況。那么&#xff0c;Led顯示屏出現花屏是什么原因呢?下面偉…

【javascript】獲取 格式化時間

function getDate() {var myDate new Date();var month myDate.getMonth() 1;var day myDate.getDate();month (month.toString().length 1) ? ("0" month) : month;day (day.toString().length 1) ? ("0" day) : day;var result myDate.getF…

深度強化學習和強化學習_深度強化學習:從哪里開始

深度強化學習和強化學習by Jannes Klaas簡尼斯克拉斯(Jannes Klaas) 深度強化學習&#xff1a;從哪里開始 (Deep reinforcement learning: where to start) Last year, DeepMind’s AlphaGo beat Go world champion Lee Sedol 4–1. More than 200 million people watched as …

制作一個大風車加載條

一、前言 不想使用普通的那種轉圈的加載條&#xff0c;所以找了一個大風車的圖片&#xff0c;想要用旋轉的大風車來表示加載中。   一般都會想著將大風車圖片設置成ImageView組件&#xff0c;然后給這個組件添加一個旋轉動畫就可以了&#xff0c;但是我突然想到我是想寫加載條…

Android OkHttp完全解析 是時候來了解OkHttp了

Android OkHttp完全解析 是時候來了解OkHttp了 標簽&#xff1a; AndroidOkHttp2015-08-24 15:36 316254人閱讀 評論(306) 收藏 舉報分類&#xff1a;【android 進階之路】&#xff08;67&#xff09; 版權聲明&#xff1a;本文為博主原創文章&#xff0c;未經博主允許不得轉載…

c盤users的用戶名怎么改_做完這幾個操作,我從C盤中清理了30G垃圾文件

信息技術土著&#xff0c;一個有營養的公眾號有個存在學說&#xff0c;比說一個人的身體某部位&#xff0c;如果不痛&#xff0c;你很少感覺他是存在的&#xff0c;但是某一天&#xff0c;因為某種原因&#xff0c;它突然很痛了&#xff0c;然后你每時每刻都會感覺到它的存在了…

linux complete函數,Linux驅動中completion接口淺析(wait_for_complete例子,很好)

completion是一種輕量級的機制&#xff0c;它容許一個線程告訴另外一個線程工做已經完成。能夠利用下面的宏靜態建立completion&#xff1a; DECLARE_COMPLETION(my_completion); linux若是運行時建立completion&#xff0c;則必須采用如下方…

vue.js 全局應用js_如何在不到7分鐘的時間內測試您的Vue.js應用

vue.js 全局應用jsby Mukul Khanna由Mukul Khanna 如何在不到7分鐘的時間內測試您的Vue.js應用 (How you can test your Vue.js apps in less than seven minutes) Before we dive into the implementation, let’s get a few concepts cleared.在深入研究實現之前&#xff0c…

MongoDB在Linux下常用優化設置

MongoDB在Linux下常用優化設置以下是一些MongoDB推薦的常用優化設置。在生產環境下選取合適的參數值&#xff0c;例如預讀值和默認文件描述符數目等&#xff0c;會對系統性能有很大的影響。1、關閉數據庫文件的 atime禁止系統對文件的訪問時間更新會有效提高文件讀取的性能。這…

iOS常用第三方庫大全,史上最全第三方庫收集

下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件。SVPullToRefresh – 下拉刷新控件。MJRefresh – 僅需一行代碼就可以為UITableView或者CollectionView加上下拉刷新或者上拉刷新功能。可以自定義上下拉刷新的文字說明。具體使用看“使用方法”。 &#xff08;國人寫…

ipconfig沒有顯示ip_TCP/IP 協議修復網絡問題

nternet 在 TCP/IP 協議上工作&#xff0c;如果 TCP/IP 協議堆棧在 Windows 或任何其他操作系統(例如 Linux 或 MacOS)中無法正常工作&#xff0c;則您的 Internet 連接會出現問題。解決 Internet 問題的最佳方法是重置 TCP/IP 堆棧設置。如何在 Windows 中重置 TCP/IP 堆棧&am…

mysql卸載

先執行mysql安裝程序&#xff0c;點擊移除&#xff0c;然后再刪除對應的安裝路徑&#xff0c;必要的時候還要刪除注冊表信息。轉載于:https://www.cnblogs.com/772933011qq/p/6007752.html

mysql-linux64,Linux64下mysql安裝和開辟

1.1地址&#xff1a;http://www.mysql.com/downloads/mysql/5.5.html&#xff03;downloads版本&#xff1a;5.1.68平臺&#xff1a;linux generalGeneric Linux (glibc 2.3) (x86&#xff0c; 64-bit)&#xff0c; RPM Package版本&#xff1a;MySQL Server(MySQL-server-5.1.…