Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Emacs basics' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Emacs basics
Authored by: paulio on Aug 12, '04 11:33:00AM

WoW! How many normal people know anything about Emacs? Bare minimum knowledge:

<ctrl-s> starts incremental search mode
arrow keys stop the mode

<ctrl-x><ctrl-s><ctrl-x><ctrl-c> saves and exits
<ctrl-x><ctrl-c> exits without saving



[ Reply to This | # ]
Emacs basics
Authored by: allentown on Aug 21, '14 10:05:15PM

Agreed, it's as if the OP wants people to know they are using some alternate editor, and it's not vi/vim so it must be spurt cool. On a hint like this I also see people saying to open TextEdit, make sure to alter your preferences to plain text, etc, or download TextWrangler.

We are working on a file deeper in the system that the Finder readily shows us. Actually, Apple hides ~/Library from the user on a default install.

In these cases, I say, why not take the safe road, don't introduce any strange characters, don't convert tabs to spaces, or spaces to tabs, all things that can happen if you open the file in TextEdit, TextWrangler, or any GUI based editing app. I think TextMate may spare you any troubles.

Either way, just use pico, which has been aliases to nano, using the -w flag to make sure word wrap does not truncate any long files, like a log file.

It is very easy, and all the instructions are right there in the editor. For lightweight edits, I still use it to this day, and I am have used and tried all the alternative editors out there, always on a quest for just the right one.

Here is how simple it is:
pico -w ~/path/to/file/words.txt
That will open the file called words.txt, if words.txt does not exists, it will open a window called words.txt which when saved, will put the file words.txt at that path.

You use the arrow keys to move around. There are shortcuts to move around more easily, cut entire lines, and a lot more. It is in all honesty, a pretty capable editor if you take the time to set it up. It even has full preferences that can be saved instead of passing them on the command line every time, which you put at ~/.nanorc

Instructions on how to save are with the rest of the instructions at the bottom of the window. There is also a help section, where you can really dig into how the app works. Once you have made your changes, press control-x which will make nano ask you if you want to save, press the letter "Y" and it will ask you the name of the file you want to write out, this is your opportunity to write over the existing file, or perform what we all know as a "save as". I just hit the enter key and it will write over the file.

This returns you to the shell as it was before you entered into pico/nano. If you issue ls -la you can look at the date on the file you just edited and see that it has been changed. You can also run `cat ~/path/to/file/words.txt` and see the changes really quickly.

For quick edits just use nano, which is the same as pico more or less, and in this case, they are interchangeable as Apple has linked the call to pico to nano, as you can see here:

Here is where the "binary" of pico is:
$whereis pico
/usr/bin/pico

If we list the "binary" of pico and learn a little about it we can see it is in fact not a binary, but a link to another app called nano, which is a binary…
$ls -la /usr/bin/pico
lrwxr-xr-x 1 root wheel 4 Mar 5 00:16 /usr/bin/pico -> nano

the -> means it is a symbolic link. Both actually are full binaries, it just looks like Apple has decided that they want you using nano no whether you type in pico or nano, you are going to be forced into using nano. You can use pico if you want by calling it as it's full path, so /usr/bin/pico -w ~/Library/Spelling/LocalDictionary

Here is quick way to prove that they are in face full binaries, compiled, and Apple is pushing one to be used over the other, probably for good reason, there may be bugs in pico. They are darn near identical apps.

Here is a `file` listing of them to show they are compiled as 64 bit binaries:
$file `whereis nano`
/usr/bin/nano: Mach-O 64-bit executable x86_64

$file `whereis pico`
/usr/bin/pico: Mach-O 64-bit executable x86_64



[ Reply to This | # ]