Y'herd thisun? 

“Now with NuGet!!!!... just grab a library because developers are too darned stupid to get into code. I dunno WROX, this attitude (and the overwhelming MVC3 EF-ONLY blackbox approach that the book and MS are more-than-gently pushing) brings back the days of forms plastered with MicroHelp VBXes. Ah well, at least we all glue the libraries together with semicolons now ;-).”

from this "Professional Book" review by Smith

MONO/Ubuntu part 5 - NANO quickies for 95% of the jobs


A real quickie on nano

Starting into Linux you get hit real fast with the implication or the flat-out statement that "Real men use vi". Yeah, ok. Got a few weeks or months to train your fingers for yet another set of left-field key combos?

As a developer you've already mastered some of the best editors ever made; VisualStudio, Eclipse and NetBeans, FlashDevelop and UltraEdit. Your personal list may differ but the fact remains that you've already got years of real tools and loads of hotkey memorization behind you. And it's also a fact that when we get on a box to change a config we all yell 'Shit!" when the file opens up - eventually - in our beloved VS. Geekness doesn't doesn't decide the "gotta have" tool for a real need.


In Windows, Notepad is the king when you want to get on a box, make a quick change and just get on with development. In Linux, let the server admins have the cult of vi, you can get the job done with "that newbie tool" nano.

nano is a geekronym; It stands for "Not ANOther text editor". The history is that when the University of Washington created the Pine email agent, they created a simple little editor for it called Pico ("PIne COmposition editor"). Pico wasn't the type of open source that extremists liked so the free-the-bits people stole its features and style, put the result under the GNU license, and called it "nano".

Nuff background, it's just a stickin' notepad :-).

Start nano at the Ubuntu commandline with "[sudo] nano [path to file to open or create]" and your terminal is filled with its humble but trusty goodness.

Along the bottom you see the most common options, the "^" symbol means use the Control Key with the hotkey. But those aren't all of the options, if you hit CTL-G you'll get a larger list... and see that your knee-jerk thought of hitting F1 would have also brought up the help screen :).

Scroll through that list and you'll see that while some of the hotcombos are geeky and some of the mnemonics are a stretch, you have quite a useful array and even multiple options depending on your fingering druthers. Do take note that where the help screen shows a combo starting with "M" they really mean - for Windows, Mac and LinuxDesktoppers - to use the ALT key.

Now here's the tip this page is named for: The descriptions in the Help can be misleading AND there are a couple of very helpful hotkeys that the help screen doesn't show.

1) The main options say that you can use CLT-K to "Cut Text", that means to cut the *entire line* that the cursor is on. While you'll use that a lot for deleting, remember that it is a CUT, so it takes the line out of the file and puts it in the primary Buffer (similar to but not exactly the same as a "clipboard").

2) CTL-U says "UnCut Text", that's just CamelSpeak for "paste" ;-). What may throw you is that unlike Windows/Mac/Linux clients, nano uses Buffers that grow as you add to them, so if you CTL-K a line then CTL-K another line then CLT-K yet another line then when you use CLT-U you will not just paste in the last line that you cut, you will instead paste in all three lines; all of the lines that were put in the buffer since the last CLT-U.

Some tipsters say that this is how you have to do multiline copy & paste with nano, that's not correct (see tip 6 below)

3) You can use your standard PageUp and PageDown buttons to move up and down a full screen's worth of text. You don't have to use CTL-Y and CTL-V.

4) CTL-O is labelled "WriteOut", that means to save the file contents without closing the nano instance down.

5) CTL-W is "find". Hit that combo and at the bottom of the screen a reverse-color area will appear, type in the text you're looking for, hit enter and the first occurance wil be highlighted. Hit CTL-W again and bang enter to find the next instance, or type something else before hitting enter to change the search.

6) 6 is the unmentioned copy & paste key (6 with CTL and 6 with ALT). You aren't limited to just copying full lines and you aren't limited to one full line at a time. Use your arrow keys to put the cursor at the start of any text you want to copy. Use CTL-6 to set a start marker. Now move your arrow keys up or down and see the selection grow from that point...

When you've got all the required text highlighted, you can use the standard CLT-K to cut it OR, the undocumented part, press ALT-6 to copy it to the buffer without cutting it out of the file. That's going to go a long way for you.

Search the web and you'll find more un-helpscreened nano options, with them and the documented ones in the help file you'll likely find that the need to become a VI person diminishes greatly.

Oh, there is one more tip. It's not just for nano, but when using nano it becomes even more useful. When you're remotting in from a GUI client (Mac, Linux or Windows) using SSH or PuTTY, you can use your client mouse to highlight any text and your client CTL-C to copy the remote text selection to your client machine's clipboard.

Useful, but not earthshattering? Wait til you see its sister...

To paste any text *from* your client machine clipboard *to* nano, just put the text in your client clipboard, then activate your ssh/PuTTY terminal and use the arrowkeys to move the nano cursor to the target location. To paste that text across the wire, just click your mouse's RIGHT button.

Like I said, this isn't just for nano, it works for copying single lines to and from a client to the server's commandline, but when you're in nano it's not limited to a single line, you can paste in loads of remote text all at once with the option.

hope it helps.

Up next: Firewall the server with UFW

jump to:

  • 1: Why?
  • 2: Installation
  • 3: Update the OS with APT
  • 4: Remoting to the box with SSH
  • 5: NANO quickies for 95% of the jobs
  • 6: Firewalling Ubuntu 8.10 Server
  • 7: Installing Apache2 and MONO
  • 8: Test client host files
  • 9: Configure MONO on Apache2
  • 10: Apache default pages
  • 11: Handling Apache and Mono Errors
  • 12: Subdomains and Christian porn
  • 13: Virtual Host Tweak: unmanaged cAse sensitiviTy
  • 14: Managed cAse sensitiviTy
  • 15: Managing files and folders
  • 16: Logging Apache Accesses and Errors
  • 17: Ubuntu Task Managers
  • 18: Ubuntu Services and Service Managers
  • 19: Installing Oracle 10g XE Server
  • 20: Connecting Mono to Oracle

  • home     who is smith    contact smith     rss feed π
    Since 1997 a place for my stuff, and it if helps you too then all the better