使用 -R/--recurse
在源文件根下执行,就会生成 tags 文件
[root@h102 forklift_etl-1.2.2]# pwd
/usr/local/rvm/gems/ruby-2.3.0/gems/forklift_etl-1.2.2
[root@h102 forklift_etl-1.2.2]# ls
bin example forklift_etl.gemspec forklift.jpg Gemfile Gemfile.lock lib LICENSE.txt Rakefile readme.md spec template
[root@h102 forklift_etl-1.2.2]# ctags -R *
[root@h102 forklift_etl-1.2.2]# ls
bin example forklift_etl.gemspec forklift.jpg Gemfile Gemfile.lock lib LICENSE.txt Rakefile readme.md spec tags template
[root@h102 forklift_etl-1.2.2]# file tags
tags: Exuberant Ctags tag file text
[root@h102 forklift_etl-1.2.2]# wc tags
165 1206 16481 tags
[root@h102 forklift_etl-1.2.2]# head -n 20 tags
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
Base lib/forklift/base/connection.rb /^ module Base$/;" m class:Forklift
Base lib/forklift/base/logger.rb /^ module Base$/;" m class:Forklift
Base lib/forklift/base/mailer.rb /^ module Base$/;" m class:Forklift
Base lib/forklift/base/pid.rb /^ module Base$/;" m class:Forklift
Base lib/forklift/base/utils.rb /^ module Base$/;" m class:Forklift
Connection lib/forklift/base/connection.rb /^ class Connection$/;" c class:Forklift.Base
Connection lib/forklift/transports/csv.rb /^ module Connection$/;" m class:Forklift
Connection lib/forklift/transports/elasticsearch.rb /^ module Connection$/;" m class:Forklift
Connection lib/forklift/transports/mysql.rb /^ module Connection$/;" m class:Forklift
Csv lib/forklift/transports/csv.rb /^ class Csv < Forklift::Base::Connection$/;" c class:Forklift.Connection
ERBBinding lib/forklift/base/mailer.rb /^ class ERBBinding$/;" c class:Forklift.Base.Mailer
Elasticsearch lib/forklift/patterns/elasticsearch_patterns.rb /^ class Elasticsearch$/;" c class:Forklift.Patterns
Elasticsearch lib/forklift/transports/elasticsearch.rb /^ class Elasticsearch < Forklift::Base::Connection$/;" c class:Forklift.Connection
EmailSuffix example/transformations/email_suffix.rb /^class EmailSuffix$/;" c
[root@h102 forklift_etl-1.2.2]#
Tip: 在包含有tags文件的目录中,就可以直接使用 vim 进行定位了,也可以将 tags 文件写到 vimrc 中,这样就不用局限于当前路径
使用 vim -t <tag>
来定位标记
[root@h102 forklift_etl-1.2.2]# vim -t forklift
...
...
...
会获得所有此标记的定义
# pri kind tag file
1 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
2 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
3 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
4 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
5 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
6 F f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
Type number and <Enter> (empty cancels):
只用选择一个序号,就直接跳转过去了
当光标在 generate 时
...
...
if ['--generate', '-generate'].include?(ARGV[0])
generate
else
run_plan
end
...
...
使用 Ctrl + ]
可以瞬间跳转到光标所在的函数定义处
...
...
begin
require 'forklift'
rescue LoadError
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/forklift.rb"
end
def generate
p = Dir.pwd
Dir.mkdir "#{p}/config"
Dir.mkdir "#{p}/config/connections"
...
...
使用 Ctrl + T
又可以跳回来
在文件里也可以对标记定位
使用 :tag <tag>
比如: 对 forklift
标签进行定位
...
...
Dir.mkdir "#{p}/template"
Dir.mkdir "#{p}/transformations"
Dir.mkdir "#{p}/transports"
:tag forklift
...
...
Dir.mkdir "#{p}/pid"
Dir.mkdir "#{p}/template"
Dir.mkdir "#{p}/transformations"
Dir.mkdir "#{p}/transports"
# pri kind tag file
1 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
2 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
3 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
4 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
5 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
6 F f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
Type number and <Enter> (empty cancels):
根据左边的数字,就可以快速跳转
ts tf tl tn tp
在 (ex command) 模式中
Command | Commant |
---|---|
:ts | 列出所有当前标签位置 |
:tf/tfirst | 跳转到和当前标签相同的第一个标签位置 |
:tl/tlast | 跳转到和当前标签相同的最后一个标签位置 |
:[count]tp/[count]tprevious | 跳转到和当前标签相同的前N个标签位置 |
:[count]tn/tnext | 跳转到和当前标签相同的后N个标签位置 |
对于 tp 和 tn 而言,前面加上数字后可以直接跳过指定个数的标签
ts 后
# pri kind tag file
> 1 F C f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
2 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
3 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
4 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
5 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
6 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
Type number and <Enter> (empty cancels):
3tn 然后 ts
# pri kind tag file
1 F C f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
2 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
3 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
> 4 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
5 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
6 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
Type number and <Enter> (empty cancels):
tl 然后 ts
# pri kind tag file
1 F C f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
2 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
3 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
4 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
5 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
> 6 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
Type number and <Enter> (empty cancels):
3tp 然后 ts
# pri kind tag file
1 F C f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
2 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
> 3 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
4 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
5 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
6 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
Type number and <Enter> (empty cancels):
tf 然后 ts
# pri kind tag file
> 1 F C f forklift lib/forklift/transports/mysql.rb
class:Forklift.Connection.Mysql
def forklift
2 F f forklift lib/forklift/base/logger.rb
class:Forklift.Base.Logger
def forklift
3 F f forklift lib/forklift/base/mailer.rb
class:Forklift.Base.Mailer
def forklift
4 F f forklift lib/forklift/base/pid.rb
class:Forklift.Base.Pid
def forklift
5 F f forklift lib/forklift/transports/csv.rb
class:Forklift.Connection.Csv
def forklift
6 F f forklift lib/forklift/transports/elasticsearch.rb
class:Forklift.Connection.Elasticsearch
def forklift
Type number and <Enter> (empty cancels):
在命令模式下 :tag <tag>
后面的 <tag>
可以自动补全
使用 tab 键自动补全
在命令模式下 :tags
可以看到过往的标签记录
...
...
def drop!(table, database=current_database)
:tags
# TO tag FROM line in file/text
1 6 forklift 12 bin/forklift
2 1 forklift 25 def forklift
> 3 1 connect 16 lib/forklift/transports/elasticsearch.rb
Press ENTER or type command to continue
yum install ctags
ctags --version
ctags --list-languages
ctags --list-maps
ctags --list-kinds
ctags -R *
file tags
head -n 20 tags
vim -t forklift
Ctrl+]
Ctrl+T
:ta
:ts
:tf
:tl
:[n]tn
:[p]tp
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。