Tag Info

Hot answers tagged

16

You pressed Ctrl+S instead of Ctrl+O to save the file. Ctrl+S is an old flow-control key combination to pause the transmission, and stop scrolling, of data to a terminal (internally, the code sent is called XOFF). Ctrl+Q (XON) is the complement to start transmission and resume scrolling. Nano ignores these code since it doesn't use scrolling. The ...


14

It should be pointed out that Mac OS X uses \n a.k.a linefeed (0x0A) now, just like all other *nix systems. Only Mac OS versions 9 and older used \r (CR). Reference: Wikipedia on newlines.


14

No, you can't give a running program permissions that it doesn't have when it starts, that would be the security hole known as 'privilege escalation'. Two things you can do: Save to a temporary file in /tmp or wherever, close the editor, then dump the contents of temp file into the file you were editing. sudo cp $TMPFILE $FILE. Note that it is not ...


13

You typed the XOFF character Ctrl-S. In a traditional terminal environment, XOFF would cause the terminal to pause it's output until you typed the XON character. Nano ignores this because Nano is a full-screen editor, and pausing it's output is pretty much a nonsensical concept. As to why the wording is what it is, you'd have to ask the original devs.


11

In Vim you can also just do the global replace on the start of all lines: :%s/^/;/


10

The pipe symbol is sending the ouput of nano to the input of the uniq command. However, nano is still running and receiving your keyboard input. It's just that you can't see its ouput as uniq won't ouput it's results until it sees an End-Of-File (this isn't important to the question). When you press ctrl-c it is 'caught' by nano, but it does not cause it ...


8

In Vim: gg0<ctrl-v>GI;<Esc>


5

The only thing coming close to what you want is option to display your current cursor position. You activate it by using --const (manpage: Constantly show the cursor position) option or by pressing AltC on an open text file.


4

jw013 points out in another answer that Mac has now switched to the *nix standard \n. Previously, Mac OS was \r (carriage return, 13/0x0D); Windows is \r\n, and *nix are \n (linefeed, 10/0x0A). I'm not certain for the more obscure systems, but I'd guess nearly everything else is also \n. The difference comes from the days of the teletype when \n would ...


4

From the tmux FAQ: ****************************************************************************** * PLEASE NOTE: most display problems are due to incorrect TERM! Before * * reporting problems make SURE that TERM settings are correct inside and * * outside tmux. * * ...


3

I did some research and find it is not too hard. To open the current selected file in ranger in a new pane (to the right) in an ad-hoc manner, you can first go to ranger's command line (by pressing :) and then type shell tmux splitw -h 'vim %f' following by the <Enter> key. To achieve this with some key binding, you can set it in a configuration file ...


3

If you press Ctrl+U immediately after Ctrl+J, the justification is undone. Nano in fact tells you (the ^U shortcut description at the bottom changes from UnCut Text to UnJustify). No, I won't blame you for not noticing that. You can't unjustify if you've typed anything after Ctrl+J. Yes, that's pretty underwhelming (far from a general undo).


3

Nano is by design a very simple editor with few features. If you start wishing for anything beyond basic edition, nano isn't the right tool. Emacs is a very powerful editor; to switch line numbers on, type M-x linum-mode. If Emacs scares you and you want a text mode editor, consider Joe, where line numbers are switched on with the -linums option.


3

For a simple task like this you could use sed or perl. For a small footprint, use sed for this simple task: sed -i.old -e 's/^/;/' file This preserves a copy of the original file as "*.old" and adds a ";" at the beginning of every line. In the event that your sed isn't a GNU version (as is the case on many Unix variants), it is likely that you won't ...


2

Strike Ctrl+X. Nano captures all keyboard input and inside Nano Ctrl+C has an entirely different meaning than in the shell. If you run a nano in a separate window, you can easily see what keys you have to enter to exit. Ctrl+X


2

The shell doesn't receive you Ctrl+C, nano does. Programs are able to define custom behavior for interrupt signals and nano is one such program. To see what the custom behavior is open nano without the redirection and send it a Ctrl+C.


2

The feature wasn't added until version 2.2 http://www.nano-editor.org/dist/v2.2/TODO For version 2.2: Allow nano to work like a pager (read from stdin) [DONE] and CentOS6 uses nano-2.0.9-7 (http://mirror.centos.org/centos/6/os/x86_64/Packages/) If you decided you want the latest version, you can download from the upstream site ...


2

I just tried nano, and what I found most surprising is it doesn't even warn you that the file is read-only when you start trying to edit the file. (UPDATE: Apparently nano 2.2 does warn; 2.0 doesn't.) Here's a (basic) script that does that. It checks if you can edit the file, and if you can't, it runs "nano" as root instead. /usr/local/bin/edit (or ...


2

You can use the stat command to check the file's modification time before and after nano. Something like: oldtime=`stat -c %Y "$filename"` nano "$filename" if [[ `stat -c %Y "$filename"` -gt $oldtime ]] ; then echo $filename has been modified fi Of course, this won't detect whether nano modified the file, or some other program did, but that could be ...


2

I found the problem by comparing my saved session in PuTTY for the "problem" server to one for a "working" server. Under the terminal emulation options, I had "DEC Origin Mode initially on" checked. Unchecking this option solved the problem.


2

I am a little confused by the statement running "PuTTY over ssh". I assume you mean using PuTTY to connect to a Linux server via the SSH protocol (sorry, it's so wordy, just want to clarify). When using PuTTY, TERM should always be xterm as PuTTY (and many other graphical terminals) emulate the old xterm Terminal Emulator. The TERM value Linux implies you ...


2

An editor may or may not be multi-threaded, but, even if it is, it is unlikely to use threads for this purpose for one simple reason: doing so would not provide any advantages for normative use, and it would no doubt create developer headaches and possibly compromise features that are considered important (for normative use). Given an infinite amount of ...


2

As other answers have already explained, Ctrl+C doesn't kill Nano because the input of nano is still coming from the terminal, and the terminal is still nano's controlling terminal, so Nano is putting the terminal in raw mode where control characters such as Ctrl+C are transmitted to the program and not intercepted by the terminal to generate signals. When ...


2

You can try: Edit your .nanorc file Add line: set tempfile Now, after you finish editting your file, just press Ctrl + X, nano then quit and automatically save your file.


2

Referenced from : Wiki Saving and exiting If you want to save the changes you've made, press Ctrl + O. To exit nano, type Ctrl + X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press n in case you don't, or y in case you do. It will then ask you for a filename. Just type it in and press Enter. If you ...


2

Syntax highlighting tends to be language specific. However, if you want to do it for all files, you can simply create a very very simple language definition. I took the Perl syntax style (which treats lines starting with # as comments) from /usr/share/nano/perl.nanorc and adapted it to: syntax "All" "." color green "^\s*#.*" As far as I can tell, the nano ...


2

Once you have selected the block, you can use Alt + } to indent it.


1

From http://www.nano-editor.org/dist/v2.2/nano.html: -s <prog>, --speller=<prog> Invoke the given program as the spell checker. By default, nano uses the command specified in the SPELL environment variable, or, if SPELL is not set, its own interactive spell checker that requires the spell program to be installed on your system. Nano runs ...


1

Search and replace over 3GB of text is a hard task for any editor. The best solution in my opinion, is to use Perl. You can use perl to automatically divide the file into smaller portions and run the regex in parallel on each portion. There is lots of way you can code this into perl. I will post one example later.


1

Check out sed, the stream editor. It has a command set somewhat like vi, but doesn't read the file in to process it, it reads, modifies and writes out one line at a time (mostly, look at the manual). So you can at least reduce the time needed to read in the file (the editor has to build complex in-memory data structures) and then write it out. [I'm (not so) ...



Only top voted, non community-wiki answers of a minimum length are eligible