33

I'm a Windows user coming to Ubuntu's Bash thanks to WSL. Now I need to edit some files and I really hate Vi. Do I just have to deal with it, or is there a simpler alternative?

The features I am looking for are:

  • CLI based
  • easy to use (typing and editing should be similar to Notepad)
  • simple editing capabilities are enough

I will try to master Vim, but I need to make a quick edit right now!

13
  • It is a matter of opinion. Beginners use nano howtogeek.com/howto/42980/… . vim (vi improved) has a bit of a learning curve but it is very powerful - See linux.com/learn/vim-101-beginners-guide-vim or any vim guides or the vim tutorial , vimtutor (included in vim)
    – Panther
    May 29, 2017 at 20:12
  • Please note that this question might be closed as quite opinion-based. You might want to reword it to fit the rules of the site (e.g. what can I use as alternative to vim?) May 29, 2017 at 20:13
  • 3
    Voting to close this as opinion-based question. Word of advice: start with nano, and later transition to vim with baby-steps. It will pay off in long run because vim is on any Linux system basically May 29, 2017 at 20:19
  • 1
    As a follow up to my comment, the current title is still debatable and could lead to closing. People might consider vim itself to be "good", and this is subjective. May I suggest using the word "easier" instead? Also specifying some desired features could help in narrowing down the question. May 29, 2017 at 20:34
  • 2
    @Jos we are talking about WSL where running GUI programs can be done but is not trivial. Also the question wouldn't exists for GUI editors because they are all easier than vim. May 29, 2017 at 21:53

9 Answers 9

45

If you are looking for an alternative editor, you are not alone. Basically life is too short to learn vi and I say this being a software developer for a living. However you should learn how to exit it because it's a problem for one out of 20k programmers. Also performing some basic append/insert operation might be worth learning, because on some stubborn servers you won't find any other editor.

Now, the answer to your question is probably nano.

If you are running some automated build script, using git or running other commands, they might open vim without you wanting it. You can prevent this by running the following before proceeding:

export EDITOR=nano
11
  • 4
    "Basically life is too short to learn vi". No need to spend entire life, although one can if they love vim. I spent 2 hours watching a good tutorial on YouTube, and just kept practicing basics that I learned from the video. Now 70% of all my answers on Ask Ubuntu are written in vim. May 29, 2017 at 21:14
  • 11
    On "life is too short", I thought this essay had a good point. One of the biggest (artificial) roadblocks in learning Vim is the false premise that you need to immediately dive into becoming a "hard core" user. You don't. Use the arrow keys. Use the GUI shortcuts to copy/paste. Hang out in insert mode. Ignore tabs and registers and bells and whistles (for now). It's relatively quick to get to nano-level functionality in Vim, and you can slowly add advanced features later, as you need them.
    – R.M.
    May 29, 2017 at 21:21
  • 2
    @R.M. GUI shortcuts? May 29, 2017 at 21:51
  • 2
    @Sergiy vim makes sense if you want to use advanced features. If I were to use vim like I use nano I would just keep using nano (as a matter of fact, I do... I use vim when I am on a server on which I cannot add software, like a client's machine). May 29, 2017 at 21:52
  • 2
    @SergiyKolodyazhnyy what I wanted to say is that you should not be required to learn how to do basic operations like typing a word, a newline or exiting the program. Something like the message in this picture, I guess: twitter.com/p_redaelli/status/868385233556480000 I use CLI tools all day long, but I'm not a guy who tries to use a textual editor like it were an IDE. If I need an IDE, I open an IDE. For the rest, nano is enough for me and for 99% of users. :) May 29, 2017 at 23:38
16

It is a matter of opinion.

Beginners use nano.

vim ("vi improved") has a bit of a learning curve but it is very powerful. See this beginner's guide for vim or any other vim guides or the vim tutorial vimtutor (included in vim).

For now I highly suggest nano

nano -B /path/to/file/to/edit

-B makes a backup

Commands are issued with the control key and are listed at the bottom of the editor window.

There' a a guide on syntax highlighting see: How do I enable syntax highlighting in nano?

nano

emacs is an alternate to both vim and nano and has many benefits as well. emacs is more complex than nano. You can see emac's tour.

Just for completeness, vim + themes such as Zenburn can be quite helpful

Zenburn

9
  • 2
    Not only beginners, basically all humans that do not want to enter the vim vs emacs wars. :P May 29, 2017 at 20:32
  • Well, to be fair, you can theme vim and a .vimrc goes a long ways. vim and emacs have advanced features that are not available in nano, but it is a waste if you do not use the advanced features. For quick basic edits I use nano although overall I am a vim fanboi. kippura.org/zenburnpage
    – Panther
    May 29, 2017 at 20:40
  • Up vote for -B :D
    – Ravexina
    May 29, 2017 at 20:53
  • 1
    Learn vi/vim. :) It is on every nix device. :) Basics aren't that hard.
    – fugitive
    May 29, 2017 at 21:24
  • 4
    "emacs is more complex than nano." :p this could be the understatement of the year. May 29, 2017 at 21:53
8

as a windows power user, after trying vim and nano I found out that I need something in between, complexity-wise. so I tried slap and It was the exact thing that I was looking for.

slap image

slap is a Sublime-like terminal-based text editor that strives to make editing from the terminal easier. slap has first-class mouse support, even over SSH connection.


installation:

curl -sL https://raw.githubusercontent.com/slap-editor/slap/master/install.sh | sh
1
  • 6
    You forgot to mention the main selling point, first-class mouse support (even over an SSH connection) May 5, 2019 at 7:30
6

Tilde is exactly what you're looking for.

To quote from Tilde's homepage

Tilde is a text editor for the console/terminal, which provides an intuitive interface for people accustomed to GUI environments such as Gnome, KDE and Windows. For example, the short-cut to copy the current selection is Control-C, and to paste the previously copied text the short-cut Control-V can be used. As another example, the File menu can be accessed by pressing Meta-F.

If you're used to keyboard shortcuts like

  • Ctrl + C for copy,
  • Ctrl + V for paste,
  • Ctrl + A for select all,
  • Ctrl + Z for undo,
  • Ctrl + Y for redo,
  • Ctrl + F for find,
  • Ctrl + S for save,
  • etc...

You'll find Tilde's default shortcuts and interface overall very intuitive.

See https://github.com/gphalkes/tilde#installing-tilde for installation instructions.

Here's how Tilde looks like. A Tilde screenshot

0
4

Have you ever been frustrated that your text editor wasn’t doing what you wanted? Angered that you can’t remember...

  • ...how to find help?
  • ...what :wq means?
  • ...any of the little lisper that you read as an undergrad?

A small, brave world awaits!

While we're advocating for our favourite lightweight text editors, let me recommend the eXcellent, tiny, and fast xo (exofrills).

It's a single Python 3 file, and it has good support for syntax highlighting through Pygments (although not perfect with non-Python):

enter image description here

It also has extremely simple and useful key combinations which can be readily and easily changed to your heart's content:

enter image description here

Other features:

  • Less than 850 lines of code in a single file!
  • Syntax highlighting!
  • Regular expression matching and replacing!
  • Search history caching!
  • WTFPL licensed!
  • Fully customizable!
  • Start at non-origin locations!
  • Hop between words on a line!
  • Jump to anywhere in the file!
  • Whole file insertion!
  • Beginner friendly - maybe you are new to words!
  • Copy and paste text!
  • Line and column status!
  • Only one row of non-text editing space!
  • Both saving & loading!

The Python3 source is on github, and you can install it more easily using:

sudo apt install python3-pip
sudo pip3 install exofrills 

exofrills: your text has been edited...but you are still hungry.

Disclaimer: I am in no way affiliated with the exofrills project.

1
  • 1
    This looks very neat, +1 from me. Although that amount of exclamation marks is disturbing. :P May 29, 2017 at 23:41
3

Mcedit

This is the (seriously underrated) built-in editor of Midnight Commander. Install:

sudo apt install mc

To edit a file with it, issue

mcedit file-name
Adjustments for better usability
  • Mouse support is enabled, but better disable the annoying "Persistent Selection" by pressing F9 and going into the General menu.

  • Some of the default bindings are exotic, especially copy-cut-paste, but all are configurable via ~/.config/mc/mc.keymap under the [editor] section. That file will not exist initially, so you can grab a copy from /etc/mc/mc.keymap. For your convenience, I'm appending the one I used before I switched to Vim.

    [editor]
    Store                 =  ctrl-c
    Paste                 =  ctrl-v
    Cut                   =  ctrl-x
    Undo                  =  ctrl-z
    Redo                  =  ctrl-y
    Save                  =  ctrl-s
    EditNew               =  ctrl-n
    MarkAll               =  ctrl-a
    Search                =  ctrl-f
    SearchContinue        =  ctrl-alt-f
    Help                  =  f1
    UserMenu              =  f2
    Mark                  =  f3
    Replace               =  f4
    Copy                  =  f5
    Move                  =  f6
    Options               =  f7
    Remove                =  f8
    Menu                  =  f9
    Quit                  =  f10; esc
    SyntaxOnOff           =  f11
    SaveAs                =  f12
    SyntaxChoose          =  ctrl-alt-x
    ShowNumbers           =  alt-n
    Goto                  =  alt-l
    Up                    =  up
    Down                  =  down
    Left                  =  left
    Right                 =  right
    WordLeft              =  ctrl-left
    WordRight             =  ctrl-right
    Enter                 =  enter
    Return                =  shift-enter; ctrl-enter; ctrl-shift-enter
    BackSpace             =  backspace
    Delete                =  delete
    PageUp                =  pgup
    PageDown              =  pgdn
    Home                  =  home
    End                   =  end
    Tab                   =  tab
    Top                   =  ctrl-up
    Bottom                =  ctrl-down
    TopOnScreen           =  ctrl-pgup
    BottomOnScreen        =  ctrl-pgdn
    DeleteToWordBegin     =  alt-backspace
    DeleteToWordEnd       =  alt-d
    DeleteToEnd           =  ctrl-k
    MarkPageUp            =  shift-pgup
    MarkPageDown          =  shift-pgdn
    MarkLeft              =  shift-left
    MarkRight             =  shift-right
    MarkToWordBegin       =  ctrl-shift-left
    MarkToWordEnd         =  ctrl-shift-right
    MarkUp                =  shift-up
    MarkDown              =  shift-down
    MarkToHome            =  shift-home
    MarkToEnd             =  shift-end
    MarkToFileBegin       =  ctrl-shift-home
    MarkToFileEnd         =  ctrl-shift-end
    MarkToPageBegin       =  ctrl-shift-pgup
    MarkToPageEnd         =  ctrl-shift-pgdn
    MarkScrollUp          =  ctrl-shift-up
    MarkScrollDown        =  ctrl-shift-down
    MarkColumnPageUp      =  alt-pgup
    MarkColumnPageDown    =  alt-pgdn
    MarkColumnLeft        =  alt-left
    MarkColumnRight       =  alt-right
    MarkColumnUp          =  alt-up
    MarkColumnDown        =  alt-down
    MarkColumn            =  f13
    ReplaceContinue       =  f14
    Complete              =  alt-tab
    InsertOverwrite       =  insert
    Refresh               =  ctrl-l
    Sort                  =  alt-t
    Mail                  =  alt-m
    ParagraphFormat       =  alt-p
    MatchBracket          =  alt-b
    ExternalCommand       =  alt-u
    Bookmark              =  ctrl-u
    BookmarkFlush         =  ctrl-delete
    BookmarkNext          =  ctrl-alt-down
    BookmarkPrev          =  ctrl-alt-up
    Shell                 =  ctrl-o
    InsertLiteral         =  ctrl-q
    MacroStartStopRecord  =  ctrl-r
    ShowTabTws            =  alt-underline
    ShowMargin            =  ctrl-b
    FilePrev              =  alt-minus
    FileNext              =  alt-plus
    SelectCodepage        =  alt-e
    WindowFullscreen      =  ctrl-t
    # ExtendedKeyMap           =
    # WindowPrev               =
    # WindowNext               =
    # WindowList               =
    # WindowResize             =
    # WindowMove               =
    # LearnKeys                =
    # SpellCheckSelectLang     =
    # SpellCheckCurrentWord    =
    # SpellCheck               =
    # OptionsSaveMode          =
    # RepeatStartStopRecord    =
    # Find                     =
    # InsertFile               =
    # MacroDelete              =
    # MacroStopRecord          =
    # MacroStartRecord         =
    # History                  =
    # Date                     =
    # BlockSave                =
    # MarkColumnParagraphDown  =
    # MarkColumnParagraphUp    =
    # MarkColumnScrollDown     =
    # MarkColumnScrollUp       =
    # MarkParagraphDown        =
    # MarkParagraphUp          =
    # BlockShiftRight          =
    # BlockShiftLeft           =
    # Unmark                   =
    # MarkWord                 =
    # MarkLine                 =
    # Close                    =
    # EditFile                 =
    # ParagraphDown            =
    # ParagraphUp              =
    # DeleteToHome             =
    # DeleteLine               =
    # ScrollDown               =
    # ScrollUp                 =
    

If you like it, update your default editor by running select-editor.

2
  • Yes, mcedit is a great, easy editor. If you want a programming-enhanced version of it (e.g.: TAB-completing symbols from CTags index), you might want to checkout neomcedit.software
    – psprint
    Jun 15, 2021 at 16:20
  • This answer is also seriously underrated. Some might already know MC, but few knows its editor keys can be customized. Thank you, @Quasimodo, now MC becomes a serviceable option in my outdated distro which does not have much other options.
    – RayLuo
    Apr 2 at 7:41
3

micro seems to be right up your alley. It's a terminal editor similar to vi or nano but with much more sensible keybinds. e.g. Ctrl+C is copy, Ctrl+V is paste, Ctrl+S is save, Ctrl+Q to quit, etc. It's got built in syntax-highlighting for many languages, as well as mouse support.

If you just want to open a file, edit it, and close it, it's one of the most painless ways to do so.

3
  • cat works too! shift-ctrl-c to copy, shift-ctrl-v to paste, ctrl-d to save and quit.
    – user10489
    Jul 11, 2022 at 5:22
  • @user10489 cat doesn't have a clipboard, those are provided by your terminal emulator and aren't available in a tty.
    – typecasto
    Jul 11, 2022 at 15:18
  • Yup, too true. Doesn't change the results, however.
    – user10489
    Jul 11, 2022 at 22:19
2

You can try micro

It's natural for people who are familiar with windows, and it supports lsp

There are also some rust alternatives. Though not so powerful(But faster.).

1

While I cannot deny that I too struggled with vi in the beginning, I think an argument can be made that vi is actually very simple to learn. (When I began using Unix the choice was either vi or emacs, so at the time I chose ed, ed being a very simple line editor, which I had learned already from reading early Unix textbooks.) I use vi daily, but I probably use only a very small subset of its features.

Here's first an argument for using vi: vi exists on all systems, uses very few resources, and may be usable over unstable and slow connections, where other editors may fail or be slow and unusable. Or in situations where the system is broken, so arrow keys are not interpreted correctly (bad terminfo settings for example.) So vi can be used to fix the configuration files leading to the problem, without being affected by the problem.

And here is how to learn a useful subset of vi: First: stop thinking of vi as an interactive, terminal-GUI "editor", and see it as a programming language for manipulating text files. In the beginning "vi" stood for VIsual mode, and vi has a nonvisual counterpart ex, which is a good place to start. Type ex at the shell prompt (I will use ¬ to represent return):

$ ex¬
Entering Ex mode.  Type "visual" to go to Normal mode.
:

Now press enter.

:¬
E749: empty buffer
:

So, lets put something in it. Type "a¬", and type a line of text, then a period on a line by itself:

:a¬
Hello World¬
.¬
:

That was the append command. Easy, short and mnemonic. But it would be nice to see what is in the buffer:

:%p¬
Hello World
:

That was the print command, p, obviously. The % is a line range shorthand. Each command may be preceded by a line number or range which the command should apply to. % means "all lines". $ means the last line, and a period means the current line. A number means that particular line. A range is written n,m and a number can be added or subtracted, so .+1,$-1 mean from the next line to the second-last line. A command consisting of just a line number goes to that line. Here is the remaining small subset of commands I use:

:1i¬
this text is inserted before line 1.¬
.¬
:

:w /tmp/filename¬
"/tmp/filename" [New] 2L, 49C written
:

w writes all (or the chosen range of) lines to a file.

:1d¬

deletes line 1.

:.s/Hello/Hello,/¬
Hello, World
:.s/$/!/¬
Hello, World!

s substitutes a regular expression. It's good to know regular expressions!

:q¬
E37: No write since last change (add ! to override)

q quits. wq writes and quits. q! quits without writing, and in a similar vein, w! forces a write to a file if possible.

Now a cool one:

:p
Hello, World!
:.!tr a-z A-Z
:p
HELLO, WORLD!

! as a command filters the lines into a shell command.

And finally:

:vi¬

enters VISUAL mode. Don't be fooled. It looks like an editor, but it's still just an interactive programming shell. You just get to look at the buffer all the time, and a few more commands. In visual mode a : shows the : prompt from ex mode. The arrow keys (if they work) move around, and if they don't, then hjkl do! h left, j down, k up and l right. 0 moves to the first character and ^(think regex here!) to the first non-space character on the line. $ (regex again!) moves to the end of line. Typing :999¬ goes to line 999, naturally, just like in ex mode.

"i" enters insert mode, which now inserts on characters instead of lines, and ends with pressing escape instead of ".¬". "I" inserts at the beginning, "a" after the character under the cursor, and "A" after the end of the current line. Always press escape when done typing text. "x" deletes the character under the cursor, and "D" deletes from the cursor to end of line. "Y" yanks (copies) the current line, and "P" pastes it back. ":pu" does the same, but can be preceded by a line number. ":ya" is the ex equivalent of "Y", and again, useful to apply to a line range. I think there is a mark command as well, but I will admit I don't remember it. I don't miss it.

The above is what I use, and I know I am probably not a very "efficient" vi user. On the other hand, I do use ex's versatility, for example to script editing configuration files. Need to change your hostname foo.bar.com to www.foobar.com in a number of conf files?

for file in conf/*
do (echo "%s/foo.bar.com/www.foobar.com/" ; echo "wq") |ex $file ; done

What I am trying to say is, that I think the problem with vi is that people think of it as a difficult editor. All it takes is to change your mindset a little, and view it as a very simple yet also very powerful interactive programming language instead. So powerful that even with a subset of the available commands, you can use it to great effect - not just as an editor but as a general, scriptable tool well integrated with the rest of Unix. I doubt nano would do all of this - emacs...maybe.

3
  • 6
    Sorry but... this does not answer the question. OP asked for an alternative to vim and answers should provide that. May 29, 2017 at 23:40
  • 4
    I commend the work you put into this answer, but it doesn't really answer the question -- a tutorial on and plug for vim does not belong here at all, but it does belong on your blog.
    – cat
    May 29, 2017 at 23:47
  • 1
    This answer is exactly why so many people are asking for an alternative to the viemacs - the more we say they're unpleasant to use, the more the converted insist that we try harder to use them. Mar 21, 2019 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .