Stop learning alone!

Learn faster and stay on-track by joining this free class with other self-learners.

Register for Learning Vim from the inside now.

Learning Vim from the inside

Open Ended Class

Creator: pbr

Status: Established

Join this class!

Lesson 2: Assignment 1

Create an ID database for the Vim source code.

Read through the manual entries (or use info 'ID database') and become familiar with the following id-utils tools:

  • mkid - Creating an ID database.
  • lid - Matching words and patterns.
  • fid - Listing a file's tokens.
  • fnid - Looking up file names.

Use the mkid command to create an ID database for the Vim source code.


Using ArchLinux? ...see MasseR's homework response for this assignment if you don't want to get frustrated figuring it out for yourself.


HOMEWORK: there are two common approaches for this; running mkid in the 'vim' directory and running it in the 'src' directory. Either one works (heck, both work!) - which did you choose to use and why?

Homework Submissions

27 total

shobhitjain (Self-grade: Outstanding)
Submitted 1 week ago | Permalink | Time spent: 1 minute
javpaw (Self-grade: Outstanding)
Submitted 8 months ago | Permalink | Time spent: 5 minutes

As other persons i ran mkid in vim directory, and tested some queries using the option for regular expressions, example:

$lid -r ^buf[a-z]*

it worked great.

rainkinz (Self-grade: Outstanding)
Submitted 10 months ago | Permalink | Time spent: 45 minutes

Ran mkid from the vim dir so that I could query over all files in the codebase.

Thanks for introducing this. Had no idea about it. @dioltas thanks for examples.

toyodai (Self-grade: Pretty good)
Submitted 1 year ago | Permalink | Time spent: 1 hour

I read info of 'ID database'. I run mkid on the vim directory. I didn't know id-utils. lid command is very fast and useful.

predator117 (Self-grade: Outstanding)
Submitted 1 year ago | Permalink | Time spent: 2 minutes

no problems read manual used it in vim dir to have all files not only source

looking forward to learn id plus vim

mams827 (Self-grade: Pretty good)
Submitted 1 year ago | Permalink

alredy, good tools for the control a lot of archives, like grep, but best

nsoodak (Self-grade: Outstanding)
Submitted 1 year ago | Permalink

I'm new to id-utils, but I read the info pages and it processess plain text files in addition to source. I figure more is better in this case -- there may be relevant notes outside src/ and I ran mkid accordingly.

In 2006, Claudio Fontana modernized the build system and the code itself, and analyzed and integrated various pending patches. Package name had a minor change from id-utils' toidutils', to be more consistent with the other GNU package names.

Comments:

pbr
1 year ago

Awesome.

Thx for your contribution! Looking forward to your homework in 3, 4, + :-)

Sign up or log in to comment

uzziel (Self-grade: Outstanding)
Submitted 1 year ago | Permalink

I'm running on OS X and I've never gotten around to installing fink or Darwin Ports, so I grabbed the idutils package from gnu.org and compiled from source. No issues at all.

What was interesting for me in this exercise was the use of idutils - I have not used this package before, but I have used something similar - ctags. Ctags does something very similar to id-utils in that it builds up a tags file that identifies tokens in your project. The difference is that id-utils seems to work from the shell, while ctags builds up a tags file that you can reference from within VIM.

I've used ctags before and then set the 'tags' variable inside VIM to indicate where the tags file is. Then, when you're editing a file in your project and you run across a token, you can put the cursor over that token and type CTRL-] to jump to the definition of that token. The file where the token is defined will open up in a new buffer. To jump back to the file you were in previously, type CTRL-t.

I'm glad to have learned about the id-utils package and look forward to learning how to use it throughout this class.

bafbomb (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

done and done

bad_coder (Self-grade: Could be better)
Submitted 2 years ago | Permalink

I got it working. Thanks for introducing me to such a useful looking set of tools.

popu (Self-grade: Outstanding)
Submitted 2 years ago | Permalink
# mkid
El programa «mkid» no está instalado actualmente.  Puede instalarlo escribiendo:
apt-get install id-utils

# apt-get install id-utils
# info 'ID database'

# cd vim
vim# mkid -v 

vim# fid src/arabic.c

vim# lid buf_valid
buf_valid     src/{buffer,ex_cmds,ex_cmds2,ex_docmd,ex_getln,fileio,main,misc2,netbeans,option,quickfix,spell,term}.c


dioltas (Self-grade: Pretty good)
Submitted 2 years ago | Permalink

Running Archlinux.

Had a look at the GNU guide, and messed around a bit with the commands. Looked at this guide too: http://www.math.utah.edu/docs/info/mkid_toc.html

I also used "command --help" to find out about the commands.

Just ran mkid -v, in the vim source folder to make the identifier database. Seemed to scan through all the files ok. Used -v to enable verbose mode, so I could see what was happening.

If I understand it right it found all new tokens in the first file, and then as it went through the rest it found less new tokens. The last file tutor.pl had 0 new tokens, the second last shtags.pl had 18% new tokens (new = 17/92 = 18%) I'm just guessing here, so could be wrong. It lists the number of files scanned and number of tokens etc at the bottom. I don't understand all of the info it gives.

I then ran

$ fnid -S newline \*.txt

to list all the textfiles, which it seemed to do ok. The -S newline tells it to put a newline between each entry. I got this wrong the first time by forgetting to escape the *, which made it only list the .txt files in my current directory as the * was expanded by bash.

I ran

$ fid ./src/charset.c ./src/buffer.c

to list the common tokens between both files, which it did.

Then finally I ran

$ lid -S newline skiptowhite*

and it listed the files which had skiptowhite, followed by the files that had skiptowhite_esc.

Please correct me if I got any of this wrong.

Edit: Don't think I was supposed to post the output of all my commands! :D

Comments:

pbr
2 years ago

Above and beyond the call of duty.

But... all good! Thanks for sharing; please feel free to contribute in this fashion for other exercises as well.

Just because others are terse doesn't mean you have to be!

Thanks for your contributions. -pbr

Sign up or log in to comment

sgithens (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

No problem making these, and trying a few quick queries. It's interesting using something like this after usually just using cross referenced API docs and stuff for programming.

I can see this being useful for things javascript, which there still aren't grade javadoc type things for (especially if you're using newer sort of closure based idioms to create reusable objects rather than prototype functions)

Comments:

pbr
2 years ago

There are all SORTS of cool uses for id-utils.

How about this: with a bit of work, it can be fed the entire "/usr/share/man" manual collection.

Sign up or log in to comment

tfmoraes (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

I didn't now id-utils.

Comments:

pbr
2 years ago

Yeah, it's really useful and not a lot of people know about it. That's a good part of why I introduced it here; I use it any time I'm reviewing source code that's larger than 1 or 2 files.

Sign up or log in to comment

sedrik (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Ran it on the entire vim directory, can't say I'm to fond of the idutlis package though, annoying commands and horrible standard output (yeah can probably be changed but so far I see no reason to even bother ^^).

a little grep magic can probably do everything I need.

herrymon (Self-grade: Could be better)
Submitted 2 years ago | Permalink

first time using id utlities, works as described. Ran mkid in vim directory. Don't know what the difference is in either approaches, so I went with first option.

marocchino (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

ok. done.

thomasmagee (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Done. Did it in src as I imagine that directory will be the focus of this course..

Comments:

pbr
2 years ago

For the most part that should be fine, but you might miss out on some hits of interest outside of vim/src - for example, the README.txt in the vim directory is different than the one in the src directory; each provides valuable information.

Sign up or log in to comment

RoobZ (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Ok here. Ran mkid in vim/ for more information. Thanks for the tip on Arch, MasseR!

Comments:

pbr
2 years ago

'lid' runs so quickly, with so little overhead, to me it's quite OK if I get a little MORE than I expected rather than a little less. So, yeah, running it over the entire tree (rather than just the src directory) makes sense. OK, so... time to dive into the code, huh? :-)

Sign up or log in to comment

webframp (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

done. Ran mkid in the top level vim/ dir, the more info I have the better.

andrewferk (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

First time using id-utils. Nothing too difficult.

FlashKorten (Self-grade: Pretty good)
Submitted 2 years ago | Permalink

I started mkid in the top directory (i.e. 'vim')

This way I do not only find everything tha is in src, but each and every .c and .h file included in the package, like 'runtime/macros/maze/maze.c'...

Comments:

pbr
2 years ago

Outstanding. YES - I agree it's much better create an ID database that spans the whole thing rather than just the source directory. Some people feel that gives too much extraneous information, but I'd rather learn more than learn less, especially during an exploratory effort.

Sign up or log in to comment

symbols (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

I found the info command useful to get a better understanding. I'm on Ubuntu 9.10

info 'ID database' # good info
cd vim # same dir cloned from googlecode
mkid # makes a file 'ID' in this directory
fnid *.c # shows c files
fid src/if_python.c # shows identifiers in the C file
lid python_buffer_free # shows files with python_buffer_free in them

Comments:

pbr
2 years ago

Outstanding. Good concise info that other students will undoubtedly appreciate.

Sign up or log in to comment

Enoex (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Worked fine, pretty straightforward

MasseR (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

It took a little while to get this assignment done as the id-utils package wasn't in the main Arch Linux repositories, and it was named as 'idutils' instead of 'id-utils'.

After installing the id-utils package, I found the official GNU manual which explained the syntax and operations without using the 'man' utilities.

Comments:

pbr
2 years ago

Thanks for the info; I modified the assignment so others don't have to go through the same frustration you probably did.

pinchyfingers
2 years ago

Thanks for the heads up. 'yaourt -S idutils' does the trick.

Sign up or log in to comment

cfedde (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

no problem. Pretty straight forward as described.

Comments:

pbr
2 years ago

Awesome. I'm hopeful most/all students can get past these steps quite easily.

Sign up or log in to comment

pbr (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

You might find the following useful if you prefer reading documentation online instead of from the command line:

http://www.gnu.org/software/idutils/manual/