edit commands


20 posts
by dboucher » Mon Jun 25, 2012 7:55 pm
real newbie question here.

editing the config.txt file i type "sudo edit config.txt"
that gets me in, from there i am lost, through dumb luck i managed to mash enough keys down to allow me to edit it. now that i have edited it i don't know how to save/exit it. so if some one could point me to the keys/combination to allow me to edit and then to exit, i would be very grateful. also i cant seem to find the | or pipe command on the keyboard it shows up as ~... thanks
Posts: 2
Joined: Sat Jun 23, 2012 11:54 am
by dom » Mon Jun 25, 2012 8:05 pm
nano is an easier to use editor. The important keypresses are listed at bottom of screen. So in future
sudo nano /boot/config.txt

edit - I don't know about.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4065
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by andyl » Mon Jun 25, 2012 8:37 pm
edit is a symlink to run-mailcap. It doesn't do what you want.

If you want you can use editor - which I cannot remember what it is by default (maybe joe).

You can change the default editor by
Code: Select all
sudo update-alternatives –config editor
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by dboucher » Mon Jun 25, 2012 8:38 pm
thanks thats much easier, still cant find the key for pipe though.
Posts: 2
Joined: Sat Jun 23, 2012 11:54 am
by DirkS » Tue Jun 26, 2012 1:57 am
dboucher wrote:still cant find the key for pipe though.

Are you using a standard US keyboard? Your linux configuration seems to be for UK layout. Try <RIGHT-ALT>+~

Gr.
Dirk
Posts: 1633
Joined: Tue Jun 19, 2012 9:46 pm
Location: Staffordshire, UK
by Joe Schmoe » Tue Jun 26, 2012 2:04 am
Another approach, if you really are lost in the world of Unix editors, is to edit it on a Windows machine. Notepad ought to work.

But then, of course, you have to beware of the fact that Windows often makes it hard to do simple ASCII text edits. This is particularly true of people who think of MS Word as the only program you'll ever need...

That, and the fact that Windows editors might put CR-LF at the end of the line, instead of just LF. Now that I think about it, I think Notepad does this (so don't use Notepad), but, I think, Wordpad (which you should always use anyway, in lieu of Notepad) doesn't.

Or you could use GVIM under Windows - which is really the best solution of all...
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2866
Joined: Sun Jan 15, 2012 1:11 pm
by andyl » Tue Jun 26, 2012 8:45 am
DirkS wrote:
dboucher wrote:still cant find the key for pipe though.

Are you using a standard US keyboard? Your linux configuration seems to be for UK layout. Try <RIGHT-ALT>+~


What's that supposed to do? Doesn't get a pipe on the console for me.
The right solution will be to change the keyboard map. There is a recent thread on these forums so I won't repeat the advice there.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by SN » Tue Jun 26, 2012 9:04 am
pipe = "|" character = on UK keyboards that's the one (shifted) just just to the left of Z
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1008
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by bob_binz » Tue Jun 26, 2012 9:37 am
Another option for "pipe" is holding <Alt> and typing 124 on the numerical keypad (not the top row numbers) although this doesn't seem to work on my daft laptop with dual purpose keys and the Fn button!
User avatar
Posts: 367
Joined: Thu Feb 02, 2012 7:58 pm
Location: Stockport, UK
by AndrewS » Tue Jun 26, 2012 12:10 pm
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Newt_Othis » Tue Jun 26, 2012 12:24 pm
If you're editing Linux files via Windows, I'd recommend using Notepad++
http://notepad-plus-plus.org/

It's very user friendly and respects the format of Linux text files better than Notepad.

It's also very handy for writing Python (and other) code as it understands the structure and will colourise the text accordingly, making it easier to read.

But, as previous posters have suggested, 'nano' is nice and easy to use on the RasPi itself.
User avatar
Posts: 20
Joined: Tue Dec 06, 2011 1:12 pm
by Joe Schmoe » Tue Jun 26, 2012 12:32 pm
heh. I don't think I could handle "nano" - I don't like WordPerfect-like editors.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2866
Joined: Sun Jan 15, 2012 1:11 pm
by andyl » Tue Jun 26, 2012 3:39 pm
Joe Schmoe wrote:heh. I don't think I could handle "nano" - I don't like WordPerfect-like editors.


nano isn't anything like WordPerfect. The commands bear some resemblance to WordStar.

But honestly there are 101 different editors for Linux - you should be able to find one to suit you.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by RaTTuS » Tue Jun 26, 2012 3:42 pm
vi -
use it
abuse it
learn it
it's always there
2 things to remember
esc:wq <- write and exit
esc:q! <- exit don't do anything

;-p
http://www.catb.org/esr/faqs/smart-questions.html <- ask smart Questions
"That's not right, the badgers have moved the goalposts."
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
User avatar
Posts: 5590
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by geep999 » Tue Jun 26, 2012 6:12 pm
joe is a nice and simple basic editor
Code: Select all
sudo apt-get install joe

ctrl k x - save and exit
ctrl c - exit
Cheers,
Peter
User avatar
Posts: 28
Joined: Fri May 18, 2012 10:20 pm
Location: East Herts, UK
by jojopi » Tue Jun 26, 2012 7:19 pm
joe is a horrendous abomination
Code: Select all
sudo apt-get remove joe
;)

A list of editors in debian, and quick-reference for the commands of the two true editors, emacs and vi: http://qref.sourceforge.net/quick/ch-edit.en.html

(I can not find the above in the current version of the debian reference.)
User avatar
Posts: 2122
Joined: Tue Oct 11, 2011 8:38 pm
by Newt_Othis » Tue Jun 26, 2012 8:52 pm
I'm always impressed at how passionate people can get about a text editor! :D
User avatar
Posts: 20
Joined: Tue Dec 06, 2011 1:12 pm
by Joe Schmoe » Tue Jun 26, 2012 9:46 pm
Newt_Othis wrote:I'm always impressed at how passionate people can get about a text editor! :D


As a developer, it is what you spend most of your time in. It had better be good.
It's like your bed; you spend a lot of time there, you want it to be comfortable. And what is comfortable is a very personal decision.

P.S. Yes, I misspoke. I meant Word*, not WordPerfect. Sorry 'bout 'dat.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2866
Joined: Sun Jan 15, 2012 1:11 pm
by jojopi » Tue Jun 26, 2012 10:37 pm
Actually it is the abominable joe (no relation) that borrows its keystrokes (in the default, jstar, mode) from wordstar. (A decision that looks increasing weird, especially for beginners, since nobody under thirty has even heard of wordstar. Maybe in its jmacs and jpico modes it is not so ripe for uninstallation.)

nano's commands are based on those of pico, the composer of the old mail client, pine (which lives on as alpine). They are a very small subset of emacs' commands, with a few of the keystrokes repurposed as exit, save, etc. (to avoid multi-character sequences) and then back-named as "write^Out" to make them seem logical.

nano is actually very good for beginners (unlike joe), and it is also fine for casual editing of human text files and for small configuration files like /boot/config.txt. It even has basic syntax highlighting. Where it loses out to the real editors is that is has no advanced features (like regular expressions) at all.
User avatar
Posts: 2122
Joined: Tue Oct 11, 2011 8:38 pm
by W. H. Heydt » Wed Jun 27, 2012 12:39 am
I'll second the vote for vi. But then, I learned to use vi on an ADM-3A in bsd 2.9 unix on a PDP-11/70....
Posts: 1784
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)