C Compiler Exists Entirely In Vim

8cc.vim is a C compiler that exists as pure Vimscript. Is it small? It sure is! How about fast? Absolutely not! Efficient? Also no. But does it work and is it neat? You betcha!

Ever typed :wq to write the buffer and exit in Vim? When you do that, you’re using Vimscript. Whenever one enters command mode : in Vim, one is in fact using a live Vimscript interpreter. That’s the space in which this project exists and does its magic. Given enough time, anyway.

Vimscript itself was created by [Bram Moolenaar] in 1991. The idea was to execute batches of vim commands programmatically. It’s been used for a variety of purposes since then.

8cc is a lightweight C compiler that has been supplanted by chibicc, but that doesn’t matter much because as author [rhysd] admits, this is really just a fun concept project more than anything. It may take twenty minutes or more to compile “hello world”, but doing it entirely from within Vim is a trip.

36 thoughts on “C Compiler Exists Entirely In Vim

    1. geany > micro > nano > vim > emacs
      For people who like easy keybinds; I don’t know if I will try to learn vim or emacs more which would take a lot of time.

        1. I used to look down on Geany. But it’s actually really good. The navigation panel will automatically recognize functions or, if you’re coding in assembler, subroutines. Being able to jump to a subroutine simply by clicking on the name in the navigation panel makes it infinitely more useful than vim.

    2. Notepad++ is the golden ratio of text editors.
      Had I been forced to work under Linux OS I’d install VMWare with Windows 10 and edit text they way it’s meant to be edited.

          1. I went and installed notepadqq. Looks ok on the surface. First thing I tried didn’t work. Column select which I’ve used at work quit a bit. Also I went to their website and it looks like the project stalled back in 2019. Then to github to check last updated… A readme says it isn’t maintained anymore.

      1. So much no. Completely different applications. Nano has some smart hints on how to save, exit, etc. With that said…learn the basics of vim and you’re probably good on any system.

    3. I have always been conflicted on which to use, Vim has like text folding and vimscript, but nano is lighter and easier. I really want some simple advice on which to use, both are quite easy to use

      1. Two completely different things.

        Nano is a simple text editor. If you want to edit a text file once in a while, nano is fine. VIM is for when you want to write software and need an IDE, or when you want to write books, or when, whatever. VIM can be whatever you want and Nano is just a simple editor. Do you need all the IDE features? Do you need to write tons of technical documents? No? Then Nano is probably fine. If you want to write, start using VIM. It will improve your life, but if it’s just a once in a while thing, then Nano is just fine, but it doesn’t give you any features.

    4. Agreed, everyone should move from nano to vim.

      In all seriousness, those are two entirely different things. Nano is like notepad, VIM is like an entire operating system with an office suite build into it. They are completely different things. Nano is for people who edit a file once in a while where Vim is also able to edit a file. I’ve written books in Vim. I’ve written thousands of documents in Vim. User manuals that are shipped around the world, papers, everything you can name. It’s an entirely different use case.

  1. I think I’ll stick with gcc, or clang….. Thank you :) . Oh and nano. I used vi a lot in the early days of Linux, but prefer nano now, when working on the command line.

      1. What else do you use when you SSH into everything? No point’n click’n available :) . All my SBCs run headless (as an example) and who wants to setup VNC/RD when command line will do just fine :) .

  2. My pronouns are Vi and Vim, but there’s a special place in my heart for WordStar:
    ^Q A gnu

    Searches for, and replaces without asking, all small antelope-like creatures.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.