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

Class length: 8 weeks. Start anytime.

Creator: pbr

Status: Established

Join this class!

Lesson 3: Assignment 2

Exploring Vim

So here's where we actually get started looking at the Vim source.

Let's dive right in. Which file identifies the five mailinglists which exist to support Vim?

Please do NOT just list the actual filename in your homework; rather, answer with how you figured out which file it was.

Homework Submissions

41 total

lsqshr (Self-grade: Outstanding)
Submitted 1 month ago | Permalink | Time spent: 1 minute

I am using Fedora. No gnu idutils packaged as known. While I did this by using sublime text's multiple text search. Which serve this task perfectly. I am not sure about following

lalit (Self-grade: Outstanding)
Submitted 2 months ago | Permalink | Time spent: 1 minute

I did : lid -R grep mailing

works for me

ramkumar (Self-grade: Outstanding)
Submitted 2 months ago | Permalink | Time spent: 1 minute

I used gid, which is an alias for "lid -R grep". The file is vim/README.txt

ram@Master:~/vim$ gid mailing
README.txt:100:If you still have problems or any other questions, use one of the mailing
runtime/doc/intro.txt:98:There are several mailing lists for Vim:
runtime/doc/os_vms.txt:108:For more advanced questions, please send your problem to Vim on VMS mailing
runtime/doc/pi_netrw.txt:1741:For Windows, folks on the vim mailing list have mentioned that Pageant helps
runtime/doc/pi_netrw.txt:2642:		mailing list)
runtime/doc/uganda.txt:95:     by e-mail or by uploading the files to a server and e-mailing the URL.
runtime/doc/uganda.txt:96:     If the number of changes is small (e.g., a modified Makefile) e-mailing a
runtime/tools/efm_filter.txt:1:[adopted from a message that Ives posted in the Vim mailing list]
runtime/tools/mve.txt:1:[ The mve awk script was posted on the vimdev mailing list ]
djx (Self-grade: Pretty good)
Submitted 4 months ago | Permalink | Time spent: 5 minutes

This did the trick. -R grep so I could see the context of "mailing".

lid -R grep mailing
theabraxas (Self-grade: Outstanding)
Submitted 4 months ago | Permalink | Time spent: 1 minute

Like most of the people I ran "lid maillist -R grep". The file is README.txt

ingorenner (Self-grade: Outstanding)
Submitted 4 months ago | Permalink | Time spent: 1 minute

lid mail -R grep | grep list runtime/doc/intro.txt:97: mail-list maillist

vivekB (Self-grade: Outstanding)
Submitted 5 months ago | Permalink | Time spent: 1 minute

did lid -S newline mailing to get the result. Cross verified with good old grep command grep -r mailing *

falcor84 (Self-grade: Pretty good)
Submitted 5 months ago | Permalink | Time spent: 1 minute

Knowing about lid for 2 minutes but still automatically switching to grep to filter the search results, I ended up with the following:

lid mail -R grep | grep list
pablocubico (Self-grade: Outstanding)
Submitted 5 months ago | Permalink | Time spent: 1 minute

Just looked for "mailing" with a simple command. The result is VERY obvious. ;)

gid mailing
redwolf (Self-grade: Outstanding)
Submitted 6 months ago | Permalink | Time spent: 1 minute

README.txt:100:If you still have problems or any other questions, use one of the mailing runtime/doc/intro.txt:98:There are several mailing lists for Vim: runtime/doc/os_vms.txt:108:For more advanced questions, please send your problem to Vim on VMS mailing runtime/doc/pi_netrw.txt:1741:For Windows, folks on the vim mailing list have mentioned that Pageant helps runtime/doc/pi_netrw.txt:2642: mailing list) runtime/doc/uganda.txt:95: by e-mail or by uploading the files to a server and e-mailing the URL. runtime/doc/uganda.txt:96: If the number of changes is small (e.g., a modified Makefile) e-mailing a runtime/tools/efm_filter.txt:1:[adopted from a message that Ives posted in the Vim mailing list] runtime/tools/mve.txt:1:[ The mve awk script was posted on the vimdev mailing list ]

lid -R grep mailing
ankorrigan (Self-grade: Outstanding)
Submitted 6 months ago | Permalink | Time spent: 2 minutes

I first checked out " grep mailing * ", then " grep mailing */* " then " grep mailing */*/* " took me to runtime/doc/intro.txt. Reading it from the begining, I arrived to 5 mailing lists. ok, " grep -r mailing * " was faster ^^" I didn't know about lid, I'll take a look at this. ok I didn't achieve that the best way; reading your submits is interesting ^^" .

[edit] " lid -r mail*list " gives me this error message: " lid: can't locate `ID': Aucun fichier ou dossier de ce type (no such file or directory)" google doesn't help me for this one... [edit]: well, sorry, I skipped a lesson... going back now ^^" .

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

First tried out with the ever-familiar grep. Took a few seconds. grep -r mailing *

Then read through the comments and found out lid could be faster. First tried out lid mailing, of which the output was boring. Then tried lid -R grep mailing which seems to be the right choice for this exercise.

ravitkhurana (Self-grade: Pretty good)
Submitted 8 months ago | Permalink | Time spent: 5 minutes

lid -r mail*list

This returned the files that contain the expression. Then I opened the files in vim and searched for 'mail'.

Comments:

pbr
8 months ago

Rockin! Keep on going - the fun starts in a few lessons!

Sign up or log in to comment

davidcorns (Self-grade: Could be better)
Submitted 9 months ago | Permalink | Time spent: 5 minutes

cd ~/vim grep -R mailing * | less

Comments:

pbr
9 months ago

You'll want to copy/paste lines with carriage returns into the "comment code" section - that should preserve the line breaks. I'll show you what I mean.

Your answer comes out as:

cd ~/vim grep -R mailing * | less

I've added the needed end-of-line back in, below.

cd ~/vim 
grep -R mailing * | less

Sign up or log in to comment

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

I timed this. lid took less than a second. grep took4 seconds. What I gather now is that lid can be made to work for a specific directory tree; locate and updatedb is for the whole file system.

Comments:

pbr
10 months ago

That's right. Lid pre-indexed all the locations for the ID. Grep had to look around everywhere.

Your scope comment re: lid/locate is accurate... however with locate you're looking for filenames not file contents, whereas with lid it's the reverse.

Good stuff! Keep up the good work! -pbr

Sign up or log in to comment

shobhitjain (Self-grade: Outstanding)
Submitted 1 year ago | Permalink | Time spent: 1 minute
lid --key=token '^mail' vim/

Comments:

pbr
8 months ago

good variant! You're reading the manuals. Awesome!

Sign up or log in to comment

javpaw (Self-grade: Outstanding)
Submitted 1 year ago | Permalink | Time spent: 1 minute

my aproach:

lid -R grep -r mail-?list

The first file was the README.txt. =)

rainkinz (Self-grade: Outstanding)
Submitted 1 year ago | Permalink | Time spent: 1 minute

Used the -R option of lid as shown in the code below:

   -R, --result=STYLE
          STYLE is one of `filenames', `grep', `edit' or `none'

Very nice output:

README.txt:103:There are several mailing lists for Vim, see http://www.vim.org/maillist.php. runtime/doc/intro.txt:98:There are several mailing lists for Vim: runtime/doc/os_vms.txt:111:For more advanced questions, please send your problem to Vim on VMS mailing runtime/doc/pi_netrw.txt:1687:For Windows, folks on the vim mailing list have mentioned that Pageant helps runtime/doc/pi_netrw.txt:2551: mailing list) runtime/doc/uganda.txt:95: by e-mail or by uploading the files to a server and e-mailing the URL. runtime/doc/uganda.txt:96: If the number of changes is small (e.g., a modified Makefile) e-mailing a runtime/tools/efm_filter.txt:1:[adopted from a message that Ives posted in the Vim mailing list] runtime/tools/mve.txt:1:[ The mve awk script was posted on the vimdev mailing list ]

lid -R grep mailing
toyodai (Self-grade: Pretty good)
Submitted 2 years ago | Permalink | Time spent: 1 hour

I run lid command. And I found it in the intro.txt.

% lid -S newline mailing mailing README.txt runtime/doc/intro.txt runtime/doc/os_vms.txt runtime/doc/pi_netrw.txt runtime/doc/uganda.txt runtime/tools/efm_filter.txt runtime/tools/mve.txt

% lv runtime/doc/intro.txt

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

lid still feels very strange but lid -Sn mailing did the job, however i am still not so much convinced about lid

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

I did read the README.txt, for to know how it install, furthermore of to read the features that it has. Also I did read the mailing lists. Homework easy.

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

Issued 'lid -Sn -i mailing' (-i just in case), and figured there would be a lesson in here somewhere. I did find it a bit daunting to not have the context as grep offers, but remembered gid and lid's "style" outputs.

Comments:

pbr
2 years ago

Well, grep has a purpose too.... -R and -C 2 being useful options.

But grep doesn't give you the exploratory capacity the ID database does - it's possible to find things you'd have otherwise missed by reviewing the IDs it has found.

Sign up or log in to comment

uzziel (Self-grade: Could be better)
Submitted 3 years ago | Permalink

I originally used mkid in the vim/src directory, because silly me, I thought we were going to be looking at the VIM source code. :-P

After finding that 'lid mail' in the src directory didn't turn up anything very useful, I re-ran mkid in the vim directory and then ran 'lid mail' there, which helped me find the answer faster.

Comments:

pbr
2 years ago

Yes that's a common error, no need to be concerned. You learned! Cool.

The tool can be run on any files in any directories; it's quite useful that way. A package includes a lot of components, some of which are located goodness-knows-where.

For example, often in "conf" directories you'll find configuration files and settings you might not have otherwise known about.

Sign up or log in to comment

dioltas (Self-grade: Outstanding)
Submitted 3 years ago | Permalink

Ok, so I executed,

lid -S newline mailing\*

which listed some files in runtime/ and README.txt.

I opened some of the files, didn't find what i was looking for, then tried opening README.txt, and down at the bottom I found the 5 mailing lists, yay!

Hope that's the right one!

Comments:

pbr
3 years ago

Yup... you nailed it!

Sign up or log in to comment

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

Tried using both lid and grep. For me grep is easier, I guess I would have to start going through the files I get from lid if I had continued on that path.

sedrik@localhost ~/temp/vim $ lid mail
mail           README.txt src/INSTALLvms.txt runtime/doc/{develop,filetype,gui_x11,insert,intro,mbyte,mlang,options,os_mint,os_vms,quickref,quotes,recover,rileft,sponsor,starting,syntax,todo,uganda,usr_10,usr_23,usr_28,usr_30,usr_31,usr_41,usr_44,usr_45,version5,version6,vi_diff}.txt runtime/indent/README.txt src/po/{README,README_mingw}.txt
sedrik@localhost ~/temp/vim $ grep mail *
Binary file ID matches
README.txt:There are five mailing lists for Vim:
README.txt:For more info and URLs of the archives see "http://www.vim.org/maillist.php".
README.txt:  from (to avoid spam mail).
README.txt:If you want to join a maillist, send a message to
README.txt:	Bram Moolenaar		E-mail:	Bram@vim.org

Comments:

pbr
3 years ago

One of the purposes of this course is to familiarize students with the id-utils tools, so they can become proficient with them. Sure, grep works (albeit more slowly), but you're not learning anything new when you use it. Maybe you'll like this option?

lid -R grep mail
sedrik
3 years ago

lid -R grep mail

Did not really do it for me, sure the output was better (still a little to cluttered). That command still did not show me that README.txt contained the mailing lists, doing lid -R grep mailing gave a better result.

sedrik@localhost ~/temp/vim $ lid -R grep mail README.txt:122: from (to avoid spam mail). README.txt:135: Bram Moolenaar E-mail: Bram@vim.org (rest of output removed due to irrelevance)

pbr
3 years ago

indeed, the keyword 'mailing' works correctly for this.

For example, 'lid -Sn mailing' gives a relatively short list of hits.

dioltas
3 years ago

Didn't realise you could just do -Sn instead of -S newline, thanks!

Sign up or log in to comment

herrymon (Self-grade: Outstanding)
Submitted 3 years ago | Permalink

tried some of the id-utils commands fid mailing, gid mailing, lid mailing. lid mailing listed README.txt file.

> lid mailing
mailing        README.txt runtime/doc/{intro,os_vms,pi_netrw,uganda}.txt runtime/tools/{efm_filter,mve}.txt
> less README.txt

Comments:

pbr
3 years ago

While willingness to experiment is an awesome attribute, you'll want to spend a bit more time reading carefully through the manuals and documentation.

In this case you're fine... but what if 'fid mailing or 'gid mailing' has some side-effect you weren't aware of?

Lastly, I'm a fan of 'less' as well - but there's a read-only version of Vim that can be used for reading documents as well (and works into the theme of this class). Do you know what it's called?

Sign up or log in to comment

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

$ grep -R 'mailing list' *

README.txt:There are five mailing lists for Vim: runtime/doc/intro.txt:There are several mailing lists for Vim: runtime/doc/pi_netrw.txt:For Windows, folks on the vim mailing list have mentioned that Pageant helps runtime/doc/pi_netrw.txt: mailing list) runtime/syntax/vb.vim:" VIM and VIM-DEV mailing lists. It is by no means complete. runtime/tools/efm_filter.txt:[adopted from a message that Ives posted in the Vim mailing list] runtime/tools/mve.txt:[ The mve awk script was posted on the vimdev mailing list ] src/po/vi.po:"này??n danh sách th? (mailing list) vim-dev@vim.org" src/po/vi.po:"này ??n danh sách th? (mailing list) vim-dev@vim.org"

$ lid mailing

mailing README.txt runtime/doc/{intro,os_vms,pi_netrw,uganda}.txt runtime/tools/{efm_filter,mve}.txt

Comments:

pbr
3 years ago

Welcome to the course! I look forward to your contributions in the various exploratory exercises to come.

Sign up or log in to comment

thomasmagee (Self-grade: Pretty good)
Submitted 3 years ago | Permalink

grep -r mailing list *

Comments:

pbr
3 years ago

So as I've mentioned for other students, my hope here is to have people learn and use the id-utils tools for this.

Were you able to get id-utils installed for your Cygwin/Windows platform? If so, give it a try; it rocks.

Again, welcome aboard! I look forward to your contributions in future assignments (will you be "first to post" in a lesson 4 assignment?)

thomasmagee
3 years ago

lid is new to me and I am already seeing that I will need time to adjust.

lid mailing -> returns the appropriate result lid mailing list -> returns nothing?

I am not asking for help, because I know I still need to RTFM, but I do think that perhaps a short course on these tools might be a prerequisite for this course in the future. Perhaps I will make such a course when I get a handle on them:-)

Thanks for creating this course! It is very interesting.

pbr
3 years ago

So you've not asked for help but you have multiple hurdles here so I'll provide some guidance.

First, both your grep and your lid examples are devoid of quotes or anything to escape the space between "mailing" and "list". This could be because of markdown on this website or it could be you're omitting those and sending grep and lid multiple arguments. Those tools individually handle being handed multiple arguments like that quite differently. In greps case, the first arg is the pattern to grep for, all remaining args are filenames. In lids case, all args are patterns.

Next; IIRC you chose to run mkid in the src directory, so the database doesn't include any of the content in the parent directory, 'vim'. It's in THAT directory - 'vim' - that you'll find the mailing list information.

Definitely Read The Fine Manuals for lid and friends and by all means let me know if you have any questions with them.

You're welcome - and thank YOU for contributing; without active students, this course would be nothing.

Sign up or log in to comment

RoobZ (Self-grade: Pretty good)
Submitted 3 years ago | Permalink

I like id-utils. It's so much faster than grep.

$  lid -Sn mailing
mailing        README.txt
runtime/doc/intro.txt
runtime/doc/os_vms.txt
runtime/doc/pi_netrw.txt
runtime/doc/uganda.txt
runtime/tools/efm_filter.txt
runtime/tools/mve.txt

Comments:

pbr
3 years ago

Indeed, it is! Since all the keywords have been pre-indexed into the 'ID' database, lid doesn't have to even open the various files to answer your query; it just looks up the identifier you're looking for, and tells you where it's found.

Sign up or log in to comment

devin (Self-grade: Outstanding)
Submitted 3 years ago | Permalink

[devin vim]$ grep -i mailing *

README.txt:There are five mailing lists for Vim:

Comments:

pbr
3 years ago

Devin, grep works great for this but the id-utils can be used to find the information as well.

How would you use THEM to find the same answer?

Sign up or log in to comment

pinchyfingers (Self-grade: Pretty good)
Submitted 3 years ago | Permalink

'lid mail' 'less README.txt | grep mail'

Comments:

pbr
3 years ago

Simple is better. Good stuff.

Sign up or log in to comment

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

Instincts of course say go to the README. but using the tools from the lesson:

$ lid -S newline mailing
mailing        README.txt
runtime/doc/intro.txt
runtime/doc/os_vms.txt
runtime/doc/pi_netrw.txt
runtime/doc/uganda.txt
runtime/tools/efm_filter.txt
runtime/tools/mve.txt

Comments:

pbr
3 years ago

Awesome. Note you can abbreviate the newline separator thing as -Sn

You're nailing the intro lessons quickly; I'm looking forward to your contributions on the exploratory assignments yet to come. Great work!

Sign up or log in to comment

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

$ grep -R 'mailing' . ... ./README.txt:There are five mailing lists for Vim: ...


./README.txt

Comments:

pbr
3 years ago

Andrew, grep works great for this but the id-utils can be used to find the information as well.

How would you use THEM to find the same answer?

andrewferk
3 years ago

lid mailing, which includes the README.txt file. lid is much faster than grep.

pbr
3 years ago

Rockin. Yes, it's quite a bit faster since the ID identifier database has already been created.

Its achilles heel is that it needs to be re-run to stay accurate. In the past I've often added a 'mkid' step to my 'make build' target in the Makefile to keep the database up-to-date.

Fortunately, we're not changing the code much in this class so the database should stay relevant throughout.

Sign up or log in to comment

Enoex (Self-grade: Pretty good)
Submitted 3 years ago | Permalink

Found in README, but unfortunately it wasn't the first place I looked. Lesson learned :)

mbudde (Self-grade: Outstanding)
Submitted 3 years ago | Permalink

The README.txt file was the first file I read after downloading the sources. Information like this is usually found in the README file so that would be the natural place to look. I also looked for a file named HACKING or similar and found README.txt file in the src dir which is also quite interesting.

Comments:

pbr
3 years ago

Thanks for writing that up that way; it's EXACTLY why I made this assignment in the first place.

While I personally agree with you that README.txt is the natural place to look, there are lots of people who disagree with us.

Here's the issue: On lots of projects the README.txt gets written once, early, and hardly ever changes. THIS IS A BAD THING... but it happens. So, old-timers like me sometimes tend to ignore it and only read it if/when all else fails.

This assignment is as much about helping people rethink that bad habit as anything else.

Thanks again! Welcome aboard!

Sign up or log in to comment

FlashKorten (Self-grade: Outstanding)
Submitted 3 years ago | Permalink

gid mailing

README.txt:101:There are five mailing lists for Vim:

runtime/doc/intro.txt:98:There are several mailing lists for Vim:

runtime/doc/os_vms.txt:111:For more advanc...

...

vim $(fnid intro.txt) +98

"fnid README.txt" leads to a some trouble...

glibc detected fnid: malloc(): memory corruption: 0x09be1ee8 ***

======= Backtrace: =========

/lib/tls/i686/cmov/libc.so.6[0x4b2ff1] ...

Comments:

pbr
3 years ago

+10,000 for using the id-utils tools to solve the problem.

-1 since gid's not part of them; I think you meant lid.

+2 for sharing the problem with fnid. What distro are you running? What does fnid --version tell you?

dioltas
3 years ago

I was thinking I should have used gid after I submitted my homework.

I think gid is just an alias for lid -R grep. That's what it says in the GNU pdf anyway.

Maybe lid -Sn -R grep -i would have been better, so that it would have found "Mailing" too. In this case it there was no need for it like, it just gave more results, but just in general.

pbr
3 years ago

Yes - in general, searching for terms with case-insensitivity turned on is a GOOD idea.

Sign up or log in to comment

Tordek (Self-grade: Outstanding)
Submitted 3 years ago | Permalink
grep "mailing lists" . -R

Comments:

pbr
3 years ago

Brute force. Good job!

FYI I was surprised by how you put the -R option at the end. That's not very common; most people put command switches inbetween the command and any arguments like below. For this tool it seems to work; don't be surprised if that approach fails for some tools though.

grep -R "mailing lists" .

Sign up or log in to comment

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

looking in the obvious place worked, but useful incantations for similar tasks (though rather noisy on the VIM source) shown below

# search for things of the form <foobar@atleast.twopieces>
# ignoring binary files, recursively
grep -IRn "<.\+@.\+\..\+>" *
# same as above, but show only files that match
# the extra option is a lowercase L
grep -IRn -l "<.\+@.\+\..\+>" *
# OUCH! that's still noisy, people like to put emails in source files
# lets just look in the root
grep -In "<.\+@.\+\..\+>" *

Comments:

pbr
3 years ago

Wow that's totally over the top. You should guide a course on how to abuse grep! :-)

mams827
2 years ago

jejeje good comment, but more best the code, pure Regex

Sign up or log in to comment

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

So the main thing to learn here is that there's a README for the Vim package and separate README for the source code directory 'src'.

They BOTH deserve to be read through thoroughly.

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

I tried using the id-utils utility to find the file, which I did but the lid output was confusing so I confirmed my results with grep.

masse@libre(remote):git/vim $ lid mailing
mailing        README.txt runtime/doc/{intro,os_vms,pi_netrw,uganda}.txt runtime/tools/{efm_filter,mve}.txt
masse@libre(remote):git/vim $ vim README.txt
masse@libre(remote):git/vim $ grep mailing *
Binary file ID matches
README.txt:There are five mailing lists for Vim:

Comments:

pbr
3 years ago

I'm guessing the "confusing" part of lid's output was the curly braces?

Read through the lid manual and see if you can figure out how to make it list all the filenames separated by spaces instead of compressing them like it does. (by the way, modern shells can parse filename lists like that; one of Linux's many obscure features!)

Sign up or log in to comment

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

README.txt

$ grep -l '@vim.org' R*
README.txt

Comments:

pbr
3 years ago

OK so something tells me your 2+decades experience led you to simply KNOW you'd find that info in the README. Good job.

Sign up or log in to comment