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 3: Assignment 1

This assignment is optional.

This class is about learning and exploring the source code... but we're SO CLOSE to being able to compile Vim now, that this assignment is here for those who wish to do that.

Here are the steps for compiling:

./configure
make

It's that simple. If you have the proper compiler tools installed, you'll see make taking all the various steps to compile a local version of Vim for you.

Remember; if you run 'vim' from the command line, you'll still be running the one in your PATH. You need to run ./src/vim to run the executable you just compiled.

For me, "version 7.2.329" compiled and ran without a hitch. However a number of students have had to take extra steps. If your ./configure step fails you might have to pull in ncurses:

sudo aptitude install libncurses5-dev

or

sudo apt-get install ncurses-dev # needed for me on ubuntu 9.10

For a minimal Debian 5 lenny install you might try: sudo aptitude install libncurses-dev build-essential

One student also recommends: sudo apt-get install libgtk2.0-dev # only if you have space & time


Less Simple but better:

Feedback from students prompts me to introduce these alternative build steps. the '-j' option to make parallelizes the build; your mileage may vary.

make distclean
./configure -prefix=$HOME --enable-gui=auto \
      --enable-cscope --enable-pythoninterp --enable-fontset
make -j2
make install

This last step should install Vim in your home directory so long as you've given the configure step the proper prefix.

If you'd like you can do a 'make test' before the 'make install'. For me, the output of 'make test' left my terminal emulator in an odd state, so I've omitted it from the above.

Lastly, if you configure with prefix=$HOME then 'make install' will place executables in your 'bin' directory; ensure $HOME/bin is in your path FIRST if you want to use YOUR version of vim instead of the system version.


Going Ballistic...

So it turns out there's a whole branch of computer science dedicated to compiling vim. (kidding).

If you'd like to experiment with variations, here's an awesome resource with details on building Vim:

http://users.skynet.be/antoine.mechelynck/vim/compunix.htm

He even has instructions for Windows users:

http://users.skynet.be/antoine.mechelynck/vim/compile.htm (that said, we won't be diving into Windows in this course)


HOMEWORK: Again please do NOT submit homework unless something didn't work for you and you need assistance.

Homework Submissions

15 total

shobhitjain (Self-grade: Outstanding)
Submitted 1 week ago | Permalink | Time spent: 1 minute
rainkinz (Self-grade: Outstanding)
Submitted 10 months ago | Permalink | Time spent: 1 minute

done

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

compiled and running, next lesson ==>

uzziel (Self-grade: Could be better)
Submitted 1 year ago | Permalink
bafbomb (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

done

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

ok

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

Just used the ./configure, make method.

When I run vim it gives an error,

Error detected while processing /home/(me)/.vimrc:

line 1:

E484: Can't open file /usr/local/share/vim/syntax/syntax.vim

I checked and that file doesn't exist, so I'm thinking that on my system (Arch) that it's just kept somewhere else as my normal vim gives no problem and syntax highlighting works fine.

If I had done make install, I suppose it would have put those files where they were expected to be.

Other than that no problems.

Comments:

pbr
2 years ago

This is part of what led me to refine this lesson with the Less Simple but better approach above.

So please give that one a try and see if things don't work better for you.

The additional -prefix=$HOME param means that 'make install' will only write files into your home directory; there should be no need to 'sudo' for it to work, and also, after that, the resultant vim executable shouldn't catch the error you mentioned. ...I think.

Hope this helps!

-pbr

Sign up or log in to comment

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

I went with the first option. Got some errors after running ./configure. Installed ncurses, sudo apt-get install ncurses-dev, compiled it again. It worked, compiled version successfully runs. Although I get this little error: Error detected while processing ~/.vimrc: line 14: E484: Can't open file /usr/local/share/vim/syntax/syntax.vim Press ENTER or type command to continue

Platform is ubuntu9.10

> sudo apt-get install ncurses-dev
> ./configure
> make
> ./src/vim
Error detected while processing ~/.vimrc:
line   14:
E484: Can't open file /usr/local/share/vim/syntax/syntax.vim
Press ENTER or type command to continue

Comments:

pbr
2 years ago

That might be related to not having run a 'make install' step yet. I'm guessing you have a custom .vimrc?

I encourage other students with ideas about what might be behind this to post them. In the meanwhile I'll investigate as well.

Sign up or log in to comment

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

I'm running Mac OS X 10.6.2. I have XCode installed (you have to if you want to compile ANYTHING). I've also got macports installed too, but I don't think that played a role in my successful compilation.

This didn't work:

./configure
make

This did:

./configure --disable-darwin
make

Comments:

pbr
2 years ago

Outstanding. Thanks for the feedback; I'm sure other Mac users will appreciate it.

Does that give you a working 'gvim' / 'vim -g'? It took me a good while to figure out what it would take to make that work on Ubuntu; you might have a similarly high curb to jump for the mac.

Sign up or log in to comment

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

So although I've been able to compile vim since day one of this course, I've not been able to successfully compile gvim, or run 'vim -g'.

It took me a while to unravel why. Below are the steps I had to take on Ubuntu 9.10. Without the various libraries I needed from the build-dep package, even when I used --enable-gui=whatever it didn't take. But, as usual with Linux, a little persistence paid off.

Hope this helps if you're experiencing similar difficulties!

sudo apt-get build-dep
cd src; ./configure -prefix=$HOME --with-features=huge \
 --enable-gui=gtk2 --enable-cscope --enable-pythoninterp \
 --enable-fontset
make
make install
andrewferk (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Again, running a minimal setup of Debian 5.0 Lenny. I had to first install some packages: sudo aptitude install libncurses-dev build-essential. After that, ./configure and make worked.

Comments:

pbr
2 years ago

Hey that build-essential target is great to know about. Thanks for mentioning it!

Sign up or log in to comment

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

needed a few extra libs

sudo apt-get install ncurses-dev # needed for me on ubuntu 9.10
sudo apt-get install libgtk2.0-dev # only if you have space & time
skilleffer (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

needed to install libncurses5-dev to complete ./configure

Comments:

pbr
2 years ago

This didn't happen to me. What distro are you running?

skilleffer
2 years ago

Ubuntu Karmic

pbr
2 years ago

Odd... I'm running 9.10 myself. Had no problem w/ ./configure - what errors were you seeing?

skilleffer
2 years ago

Maybe you compiled something that uses ncurses before, and had already installed libncurses?

checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
skilleffer
2 years ago

Oh, and thanks for whipping up this course. It's a great idea.

pbr
2 years ago

Heh... you're right. I have a few custom terminal emulators installed (tilda and yakuake) and I'll bet I pulled it in when I compiled one of those.

You're welcome; glad you're enjoying the course. You might also want to say thanks to kday for launching CrunchCourse via the 'contact' link on the top bar of the page.

skilleffer
2 years ago

Yah, will do.

symbols
2 years ago

I needed to install ncurses-dev as well, ubuntu 9.10, nearly fresh VM

sudo apt-get install ncurses-dev

Sign up or log in to comment

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

Configuring and compiling went without a hitch. I did do a few things different though, and enabled GUI, cscope and python interpreter.

./configure --enable-gui=auto --enable-cscope --enable-pythoninterp --enable-fontset
make -j2
make test

Comments:

pbr
2 years ago

OUTSTANDING!

I was hoping for some feedback on this step. I'll update the assignment to include your configure line as an option the student might consider.

symbols
2 years ago

could you comment or link to info on the options you enabled (cscope, pythoninterp, fontset) and why you like them?

seems pythoninterp is for python extensions cscope is for searching/browsing source (see http://cscope.sourceforge.net/cscope_vim_tutorial.html)

not sure about fontset

Sign up or log in to comment

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

might say make -j4 for systems with 2 cpus. The rule of thumb seems to be -j(2 x #cores) where hyper threads also count as "cores"