Learn faster and stay on-track by joining this free class with other self-learners.
|
Learning Vim from the insideOpen Ended Class Creator: pbr Status: Established |
Join this class! |
Lesson 2: Assignment 1Create 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:
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 Submissions27 totalAs 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. No comments. Sign up or log in to comment 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. No comments. Sign up or log in to comment 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. No comments. Sign up or log in to comment no problems read manual used it in vim dir to have all files not only source looking forward to learn id plus vim No comments. Sign up or log in to comment alredy, good tools for the control a lot of archives, like grep, but best No comments. Sign up or log in to comment 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 Comments:Awesome. Thx for your contribution! Looking forward to your homework in 3, 4, + :-) 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. No comments. Sign up or log in to comment done and done No comments. Sign up or log in to comment I got it working. Thanks for introducing me to such a useful looking set of tools. No comments. Sign up or log in to comment # 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
No comments. Sign up or log in to comment 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: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 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: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. I didn't now id-utils. Comments: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. 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. No comments. Sign up or log in to comment 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. No comments. Sign up or log in to comment ok. done. No comments. Sign up or log in to comment Done. Did it in src as I imagine that directory will be the focus of this course.. Comments: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. Ok here. Ran mkid in vim/ for more information. Thanks for the tip on Arch, MasseR! Comments:'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? :-) done. Ran mkid in the top level vim/ dir, the more info I have the better. No comments. Sign up or log in to comment First time using id-utils. Nothing too difficult. No comments. Sign up or log in to comment 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: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. 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:Outstanding. Good concise info that other students will undoubtedly appreciate. Worked fine, pretty straightforward No comments. Sign up or log in to comment 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:Thanks for the info; I modified the assignment so others don't have to go through the same frustration you probably did. Thanks for the heads up. 'yaourt -S idutils' does the trick. no problem. Pretty straight forward as described. Comments:Awesome. I'm hopeful most/all students can get past these steps quite easily. 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/ No comments. Sign up or log in to comment |
No comments. Sign up or log in to comment