notepad.exe vs vi: Which Is More Difficult To Learn? The Answer Isn’t Quite What You Expect.

Migrating from Windows to Linux is no simple task. One of the things that some people complain about is the difficulty of text editing in console mode.

You may or may not know that Notepad.exe is actually pretty damn complicated. Just take a look at all the documented keyboard shortcuts:

New Ctrl+N
Open Ctrl+O
Save Ctrl+Save
Save As Alt, F, A
Page Setup Alt, F, U
Print Ctrl + P
Exit Alt+F4

Undo Ctrl+Z
Cut Ctrl+X
Copy Ctrl+C
Paste Ctrl+P
Delete Del
Find Ctrl+F
Find Next F3
Replace Ctrl+H
Goto Ctrl+G
Select All Ctrl+A
Time/Date F5

Word Wrap Alt, O, W
Font Alt, O, F

Status Bar Alt, V, S

Help Topics F1
About Notepad Alt, H, A

Here are some some undocumented keyboard shortcuts:

Goto Beginning of Next Word: Ctrl+Right Arrow
Goto Beginning Previous Word: Ctrl+Left Arrow

Select From Current Position To Next Word: Ctrl+Shift+Left Arrow
Select From Current Position To Previous Word: Ctrl+Shift+Left Arrow

Select From Current Position to Beginning of Line: Shift+Home
Select From Current Position to End of Line: Shift+End

This list of undocumented keyboard shortcuts for notepad are pretty long, that’s just a start from memory. If you count all the extra undocumented keyboard shortcuts, notepad has tons of functionality that is under utilized.

Did we ever notice or care that notepad had that many shortcuts? Most power users simply knew these shortcut commands by heart and never even had a second thought that notepad was difficult to learn, or poorly documented.

Using the vi editor is not complicated. I think most people just assume at first glance at a huge list of commands that it’s really hard to remember everything. It’s not that hard! Remember how ‘easy to use’ notepad seemed at first? Apply that attitude to learning vi!

The hard part about learning vi is that it doesn’t have a graphical interface for training wheels. You get right dropped right into a window that doesn’t necessarily want to help you get up and running quickly. So here are a few keyboard shortcuts for vi starting from the equivalents for notepad that are listed above:

New vi newfile
Open vi filename
Save :w[Enter]
Save As :w filename[Enter]
Exit :q
Undo u
Cut y
Paste P
Delete d
Find /text
Find Next n
Replace :%s/search/replace/g
Goto :linenumber
Help F1

Here’s where you, my readers come in. I’ve been looking all over, but I just can’t seem to find replacements for the following commands that have similar function without making things difficult:

Copy ?
Select All ?
Time/Date ?
Word Wrap ?
Font ?
Page Setup ?
Print ?

I assume since these were something I couldn’t find really easily that they are probably configuration settings, somewhere, but I’ve been looking for awhile and no luck.

Also, here is a pretty fantastic cheat sheet for vi (or vim) that I’ve found pretty handy:

vi-vim cheat sheet

Enjoy!

Few more announcements: Friday is my birthday, and I’ll be out of town. The the next several days will be pretty quiet. I’ll probably do the 6th edition of Linux Nation tomorrow morning, but that should be all you see from me until Monday, and I’ll be back with a vengeance.

Good news if anyone is keeping up with the times here, girlfriend has been quoted as asking, “can’t we just take off Windows?” Needless to day, that experiment is also going much better than I expected.

Also check out the right sidebar, Atlas carrying the Firefox icon was an idea I came up with, it was all done using Inkscape and GIMP. Let me know what you think of it. If you’re too lazy to scroll up, here it is:

atlas with firefox

See ya next week,
-Wayne

  • http://www.commmanddotcom.com Adam

    Here’s the vi cheatsheet that got me through some MSCS classes at Marquette:

    http://www.mscs.mu.edu/mscs/resources/vi_commands.html

    -Adam

  • http://lindesk.com/ Binny V A

    If your are coming to Linux from Windows, vi is probably not the best idea. Try something like gEdit or Kate.

  • http://www.fsckin.com/ Wayne

    kate and gedit are not installed on every system though. vi is on all unix based systems.

  • Slack User

    I’m personally a nano fan, and what drives me nuts about vi is it’s command modes. I press a shortcut in one mode and it inputs something, I press it in another and it deletes a line. Honestly, I find myself using :!q more than any other command in vi. I’d rather echo data to a file than mess with vi.

    But I find notepad simple because it simply works as you would expect it to. The same applies for nano (or pico). DOS uses edit and the shortcuts are a bit different but it’s not like a new language like how vi works. kedit is the GUI editor I prefer without any prior bias. but kate is just as good if not better with it’s syntax coding. Oh also for windows I really enjoy textpad (a free download) it has blcok select mode!

  • http://www.fsckin.com/ Wayne

    notepad++ is a nice free alternative to shareware

  • Steve

    Your command for cut in vi is wrong. Cut is c, copy is y (it’s short for ‘yank’). p is paste below the cursor (I seem to remember) and P (capital P) is paste above cursor…or possibly vice versa. I’m not in a place I can test it.

  • Spence

    To “select all” (press keys in this order)
    gg_vG$

    gg -> front of file
    _ -> beginning of line
    v -> visual (starts select)
    G -> end of file
    $ -> end of line

    To copy – depends on what your copying

    yy -> copy entire line
    y$ -> … to end of line
    y5 [down key] -> … following 5 lines
    .. etc

    You may also just want to just bind keys (make a new file – or append this to ~/.vimrc):

    map gg_vG$

    try pressing ctrl+a inside an opened file now…

  • Spence

    Bleh.. the above mapping was missing something (maybe this will work

    map gg_vG$

    (without the space between the

  • Spence

    grr…

    map <C-a> gg_vG$

    Edit: Wayne at Oct 21 10:45 pm
    Fixed it… ampersand lt(or gt) followed by semicolon did the trick.

  • http://www.fsckin.com/ Wayne

    That’s annoying… hmm > <

  • lelutin

    If you’re using Vim, you can also press v to select a region of text and y to copy the region. pressing V has a similar effect but for entire lines and Ctrl+v selects a block of text (very useful to insert the same text on every line by pressing I and then typing. and also very powerful if used with a filtering command: with a block of text selected, press ! and type a “filter” command like ‘sed’ with arguments. this way you can easily make complex modifications on a small subset of your text)

  • http://www.fsckin.com/ Wayne

    Great tip lelutin!

  • Pingback: vi keyboard cheatsheet « Ubuntu Life

  • cimo

    ggVG -> Select All
    :%y* -> copy all lines to system clipboard

  • http://www.uk-plc.net Ronald Duncan

    The best way to learn vi is to install vim on your windows machine and go through the vim tutorial.

    I first learnt vi through man vi and it was a nightmare. I decided to try again after playing with Elite after a 20 year break and finding that the keyboard was just so much faster than a joy stick.

    When it comes to editing vi/vim is so much faster than a keyboard and mouse.

    Using the vim tutorial was a pleasure and so much easier than trying to figure things out from man vi

    There are a few errors in your list.

    Cut is d (delete)
    Copy is y (yank)

    The keyboard cheat sheet is great, but I still recommend running through the vim tutorial. It is a quick fun way of learning vi.

    It really is worth it, and once you have managed to get into the switch between normal, command and insert mode. You become so much more productive than with any other editor.

    Because you often want to do things with a number of lines you need to be able to toggle line numbering.

    :se nu // :set number turns on line nos
    :se nonu // :set nonumber turns off line nos

    :the ex commands are incredibly powerful and

    q: gives you a command history editor in vim

    The key ex commands are

    :,s/findit/replacewith/gi
    It is a great way of learning regular expressions and
    /findit is the way to test them in vim

    :,g/findit/set of commands to apply to selection

  • http://www.uk-plc.net Ronald Duncan

    Sorry angle brackets got removed to leave
    :,s which is junk.

    With the ex commands it is :lineno,linenoCommand

    e.g.
    search
    :5,8s/findit/replace/
    or
    All lines are
    :%s/findit/replace

    using g (global) to delete all matching lines
    :%g/findit/d
    or to yank all matching lines
    :%g/findit/y

    There is one area where vi is better than vim and that is on very large files. vi does not try and load the file it just takes the first small section, so it is very fast at editing massive files.

  • Josh

    This is all good info, but I think that saying notepad is complicated because it has a lot of shortcut keys is oversimplifying a bit. I recognize most of those notepad commands, and they are pretty much all universal to most windows applications. If you know the word commands, then you know the notepad commands, etc. I haven’t used Linux much recently, but it seems that a lot of these same commands work there in the GUI apps as well? Also, as you mentioned you don’t have to use the keyboard commands in notepad, it just speeds things up, so if you forget one, you can find it in the menus. And a lot of the menu items tell you their keyboard shortcuts, so if you can find it in the menu, you can teach yourself the commands as you go. vi/vim may be more powerful, but for normal text editing, I don’t really think it is any simpler than notepad, especially the learning curve.

  • Bob

    Ok, I’m a unix systems administrator, and have been using vi for a long time, but even I have to say that this article is extremely biased. Notepad is by far easier to use, and definitely to learn.

    I don’t use it often, but when the situation calls for it, notepad has the option to use this thing called a mouse. If nothing else, this alone wins the contest for notepad.