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.mzph.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.…