a memo

Search and replace in nano

Oops, I just learned how to search and replace in nano.

I've been using this excellent little editor (which is like pico but available without pine) since 1999. I didn't know until just now that Ctl-\ intiates search and replace. How embarassing...

...but _very_ good to know.

Yeah, I've got some more nano tips.

Escape is the meta key (in Mac OSX Terminal), so when it says M-F it means Esc-F. There is no easy way to remember this, which is why it's considered meta.

You can switch between multiple buffers, kinda like screen but no shell, using Esc-< and Esc-> (Esc-, and Esc-. are mapped -- nano commands are caseless).

To open more file buffers, Ctrl-R (to open) then Esc-F to turn on multiple buffers. I think of it as "crumf". I find multiple nano buffers less annoying than screen, because fewer keystrokes.

Use nano -w to avoid wordwrap "accidents" in line-sensitive files, like config or csv files.

Ctrl-w is find. Ctrl-\ is replace. As I mentioned above, replace can be extremely useful. It can also be dangerous. Nano's interface excels at efficient manual replacement, and when you cancle (Ctrl-C)

Nano (or pico) is likely to be on any unix-like system you use. Or if not (because someone deleted it or the sysadmin only uses vi) it's an apt-get or yum call away.

By Chris Snyder on February 16, 2006 at 8:45pm

jump to top