## Text Editors

When we write programs, edit config files, or even take notes to study later, we will do that with a text editor. Echoing and cating text only gets you so far.

There are hundreds of text editors, and much like programming languages, each has its own tradeoffs. Some are simple and have a GUI, some are terminal only and are incredibly complex. Many have entire programming languages built into them, or are even shells themselves, capable of executing programs. As a general rule, use what works for you and don't seek out complexity for complexities sake. I used to use the most complicated text editor I could so I looked cool, now I use the simplest ones I can for the job at hand.

Ubuntu comes with a few text editors installed initially, but the ones we will focus on are gedit and vi/vim.

# gedit

To open Gedit, simply type \$ gedit & in the terminal, or open it from the GUI. gedit is a GUI application, and gives you a nice window, normal use of your mouse, copy/paste, and all the normal things you expect from a text editor, similar to Notepad on Windows. I use it all the time to display information and make notes, but I also program in it every once in a while.

Many people who like to think they are badasses think they are too cool for gedit. Those people are silly and you should ignore anyone who thinks that text editor choice has anything to do with how good of a hacker you are.

# Terminal-Based Text Editors vi/vim

gedit is a good option if you are on an Ubuntu desktop, but many times you just won't have a GUI at all. If you are SSH'd into a box, or using a server build, you will have to learn how to use a terminal text editor.

The default editor that comes with all Ubuntu distros is named vi. It has a more modern, more advanced successor named vim. There are plenty other terminal based text editors out there, most prominently emacs, but I think it is better to initially learn vi/vim because it has more market share. Most prominently, I often find myself using vi on computers I do not have the ability to install new programs on. If I don't have the permissions to sudo apt-get install vim or anything else, I am going to be using vi, so it's easier for me to just use that for my terminal text-editing needs. Because vi/vim are always available, I believe it is the best family of editors to learn initially.

Two other terminal-based text editors are nano and emacs. Don't worry about learning them, but it is good to know they exist. Notably, there was once something named "The Editor Wars", when nerds argued with each other if emacs or vim was better. Nobody won, everyone wasted time, and if you hear anybody today talking about why one is better than the other, ignore them. Even me.

What makes vi/vim/emacs/other terminal-based text editors special is their extensibility and keyboard based shortcuts. By offering powerful commands inside of the text editor, a programmer can speed up their navigation of a code base and type faster.

vi and vim can be considered roughly equivalent when it comes to their core shortcuts. To get an idea of how to work with vim, install it and play around with the first few chapters of the built in tutorial by running the command vimtutor from the terminal.

Hint: To close out of vim, press escape key and type ":q". To save, escape key then type ":w". Without that knowledge it can get a bit awkward for beginners.

However, the speed increase of mastering a cool text-editor is not actually that much. Even if we increase speed of typing/navigation by 10%, it won't actually make us a better programmer. Luckily, there is a form of text-editor that provides that benefit to us that we will talk more about in the programming section. For now, vim should get us what we need.

Play around with "vimtutor" and learn a few commands.

Print out a vim cheatsheet or put it on your desktop so that you can constantly reference it. The more you use it, the easier it will be to remember.

For your assignment, submit a picture of your printed out cheatsheet or a screenshot of it on your desktop. Believe me, this is for your own good.