As the title suggests, I'm looking for a command line text editor with syntax highlighting. I don't have a GUI installed and I don't intend to install one which is why I need a command line one.

I usually use nano for my text editing but this doesn't come with syntax highlighting (if it does, I don't know how to enable it). Others I have tried are Vim/Vi and Emacs. Neither of which I like.

Does anyone have any recommendations or am I going to have to settle for Vim?

Recommended Answers

All 7 Replies

A long time ago, I used Jed in a terminal. It is a nice text editor.

To enable syntax highlighting in nano you can do the following:
Use ls to list the contents of /usr/share/nano
ls /usr/share/nano
This will give you a list of files with names like {filename}.nanorc. These are the syntax highlight modules that are available.

Assuming you managed to find some syntax highlight modules, to enable them you need to create a file called .nanorc in your home directory.
So as you are using nano, lets do that with nano:
`nano ~/.nanorc'

In the file, you should include the syntax highlight modules that you want to use (or you could just include all of them!):

include /usr/share/nano/c.nanorc
include /usr/share/nano/python.nanorc
etc etc...

Finally save the file and quit. Now you should be able to see syntax highlighting any files that are of a type that you added the highlighting module for.

Personally, Vim is my command-line editor of choice. But I am also comfortable using Emacs and Nano. Vim and Emacs are both extremely powerful editors and IMHO are well worth investing some time in learning to use properly!

Member Avatar

Sublime. Closet thing you'll get to a lightweight ide.

Best thing you can do with tonnes of extra functionality.

commented: Yep my fav <3 +5

But sublime isn't a command-line based text editor is it?

Edit: Nevermind, just looked it up, sublime can run in the terminal or in a window.... Didn't know that!

Member Avatar

haha, no it is not and no I didn't know it could run in the terminal window either!

I think most the op is looking for something super lightweight to perhaps code in which is why he wants a terminal editor. It is true that you can get vim to to this, but you will have to learn a lot of commands by heart. Sublime is an inbetween, super light weight and packed with features.

I can't do without shortcodes snippets but then I code in php. Just my opinion.

The reason I am looking for a terminal editor is so I don't have to keep downloading the files to other locations to edit while coding/scripting.

I don't need extra features, it's just the syntax highlighting I need. I am currently using vim but I keep forgetting to go to insert mode when I open it.

It is true that you can get vim to to this, but you will have to learn a lot of commands by heart.

True, but it is worth learning to use some of the commands in Vim (and Emacs for that matter) as they can really boost your productivity once you know what you are doing with them. It is surprising how functionality they contain.

Personally, I found Vim a lot easier to learn than Emacs. Emacs has tons of esoteric keyboard shortcuts and named commands that take ages to memorise - I still have problems remembering Emacs shortcuts and commands from time to time. Plus there's the risk of RSI from contorting your hand to hit some of the keybinds, heh heh! Viper mode helps in Emacs - allows you to use Vi/Vim keybinds and commands in Emacs, heh heh!

Not wanting to start a holy war here or anything, but I find Vim much more intuitive to use. And that's just my opinion/experience, no offence intended to followers of the church of Emacs!

Nano is great for simple text editing tasks and is extremely lightweight, but if you want more advanced functionality/capabilities that is where Vim and Emacs excel!

I am currently using vim but I keep forgetting to go to insert mode when I open it.

Ha! After all these years using Vim, I still forget to do that sometimes.
Doesn't really bother me though!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.