42

I have recently started using Ubuntu and hence, the terminal.

As text editor, I have used the pre-installed nano. Now I wonder whether I should install and use vim as well.

What are each of those text editors' special features, advantages and disadvantages? Which one is better suited for newcomers, and for what use cases would the other be preferable?

  • 5
    Entirely your wish. – muru Jan 28 '16 at 13:02
  • 1
    if you want to know the difference you should use them both and see for yourself – Edward Torvalds Jan 28 '16 at 13:20
  • Also don't confuse vi and vim. The latter is improved version, which has many cool things, for example «text objects». – Hi-Angel Jan 28 '16 at 13:57
  • nano has smaller learning curve cumpared to vim, vi takes getting used to even more i suppose. Knowing both however will be quite useful. – Sergiy Kolodyazhnyy Jan 28 '16 at 14:13
46

Vim and Nano are completely different terminal text editors.

Nano is simple, easy to use and master while Vim is powerful and tough to master.

To differentiate, it will be better to list some features of them. Since we don't use terminal editors for normal edits or coding, I'm listing some of the most interesting features that help for the way we use them today.

Nano:

  • Easy to use and master.
  • Nano has most of the shortcuts listed at the bottom of the window, making it extremely simple to use.
  • Search function
  • Search and replace
  • "Goto line" command
  • Automatic indentation

Vim:

  • Tough to get started with and master. The editing and command modes will confuse beginners.
  • Session recovery
  • Split screen
  • Tab expansion
  • Completion commands
  • Syntax coloring

Although I hated Vim when I first met it, now I prefer it over Nano.

| improve this answer | |
  • 1
    Very nice list of features, +1. But you should prefer Markdown formatting over HTML tags in your posts whenever possible. Here is the related help center site about Markdown syntax on Ask Ubuntu which will help you to improve your future posts. :-) – Byte Commander Jan 28 '16 at 17:19
  • 11
    nano supports syntax highlighting: askubuntu.com/q/90013/158442. Correspondingly Vim supports all of the last four features mentioned for nano. – muru Jan 28 '16 at 17:48
  • "we don't use terminal editors for normal edits or coding". Uhm... :) – Neil Jun 23 '19 at 13:42
  • Vim supports goto line, which comes from its parent vi, which comes from its parent Ex. Simple type :31 in the moral mode – William Kinaan Jun 27 '19 at 10:09
53

In a nutshell: nano is simple, vim is powerful.

If you only want to simply edit some textfiles, nano will be enough. In my opinion, vim is pretty advanced and complicated to use. You should expect some time to get into it before you're able to properly use it.

Funny (but not too unrealistic) quote about vim: (source)

I've been using vim for about 2 years now, mostly because I can't figure out how to exit it.

| improve this answer | |
20

They're both text editors, but the similarity pretty much ends there. It may seem strange that two text editors could be so different. The key is that they're both specialized text editors, made for two very different tasks. nano and vim (or rather, pico and vi, which they imitate) were designed for writing e-mails and programs, respectively.

You're not meant to spend a lot of time in nano: you go in, you type up your e-mail message (or whatever you were writing), and you get out quickly. Everything is based around getting you in and out as quickly as possible, so you can get back to whatever else you were doing. It goes so far as to list all the functionality at the bottom of the window, so you don't have to waste time looking up help screens. Of course, there's only so much room at the bottom of the window, and so functionality is constrained to whatever can be expressed, alongside all other functionality, in two lines of text. The result is extremely convenient for some things.

You're meant to spend much (if not almost all) of your time in vim, so it tries to stay out of your way while helping you sling large chunks of text around quickly. A basic startup screen gives almost no information, and when you open a file you get only slightly more about where you are. And in both cases, you can't type text straight away: you start in "normal mode" and have to press i to go into "insert mode" first (there are also a few other letters you can press instead of i, offering some variations on this theme, and there are also some other modes I haven't mentioned). The learning curve is extremely steep: it comes with vimtutor to help people out, but some people have gone so far as to write entire games dedicated solely to learning vim's interface. Think about that for a second. An entire game, just to learn how to use a text editor. And people pay for it.

There is no question that nano is better for the newcomer. I'm something of a vim-zealot, and even I can't dispute that one. I've seen vim turn newcomers off of Linux in general. And if you don't plan to do a lot of text-editing, or your text-editing tasks are all fairly light (like, say, writing e-mails), then nano may be all you need.

That said, while mastering vim takes a long time, the return on investment is high. I realize that the rest of this post sounds kind of down on vim, but that's not my intent. You just need to know what you're getting into, because vim is hard. But even its default configuration contains functions that automate a lot of common (and very repetitive) text-editing tasks: you can do with a few keystrokes things that could take many minutes, or even hours, if you had to do them all manually. There are plugins and scripts that take this even further. If you're going to be doing a lot of programming, or similarly long and involved tasks (dissertations, novels, etc), then vim is ultimately the better choice, but you should still figure out nano first: if an emergency comes up and you need to do something before you've figured out the basics of vim, you'll want to be able to drop into something you're comfortable with.

Bottom line: start with nano, and move to vim if nano gets tedious.

| improve this answer | |
5

You don't need vi or vim if you like nano.

Nano is easier to use if you are not familiar with vim.

Vim is similar to vi, which is universal (it installed on almost all unix-like systems), but if you never used it before, you will need to look at some documentation/tutorial before you will be able to do anything with it.

| improve this answer | |
3

Vim is powerful, but tough to learn. It is so called "modal editor", as opposed to usual editors, like nano. Vim allows you to reach all text with just a few key presses, so if you have touch-type ability, your movement without a mouse would be even faster than with one.

So, if you do not work with text a lot (e.g. like programmers do), you may stick to whatever common editor. Otherwise I'd suggest you to learn Vim.

It is worth noting that nowadays there's more than one vim. "Vim" become sort of standard which is implemented in many other editors and IDEs as either a checkbox in settings or a plugin. For example, I use Emacs with Evil (a vim-mode plugin).

A side effect of learning Vim that for some reason nobody mentions: if you can't touch-type yet, but wanted to learn it — just learn Vim, and use it everyday. Vim forces you to move without arrows (h,j,k,l instead), and as you can't look at the keyboard every time you move, you would be forced to learn more and more key locations. This is how I learned to touch-type by the way ☺

| improve this answer | |
2

I read through the other posts. Initially I would have agreed with them. However, I have taken the time to really learn nano. It is actually quite powerful. For example, you can have syntax highlighting. You just need to configure your .nanorc file. And there are many samples that come on the server in the /usr/share/nano location. Just add an include /usr/share/nano/sh.nanorc line to your ~/.nanorc file for bash shell highlighting.

There are a large number of additional keyboard commands that you can use. I made myself a whole page of shortcuts. It is very much like using Wordstar or other text based word processors of the old days. I find now that I install nano on servers it is not on as one of my first steps because it has become so intuitive for me, and so much more efficient than vi/vim. I would not say it is more powerful, but it is as powerful.

Start with this nano cheat sheet to find a large number of the commands. If you have used emacs you will find this is very similar, but in my mind easier. I don't fault people that still use vim. There have been holy wars for years for vim vs emacs. Adding nano has just added a third very powerful editor to that discussion. But do not discount it as a weak beginners tool.

The big difference is that vim is modal and nano is not. So with vim you are constantly changing between command mode and edit mode. In nano, as in emacs, you are in one mode and your commands use special key combinations. As you use the editor more you will start to learn all the most used commands. And if you use it a lot you will learn most of them. One other note is that for the read file function there are two mode for that. Either it will read a file into the current edit buffer, or into a new buffer to go between. Make sure to look that one up.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.