LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   vi and emacs (https://www.linuxquestions.org/questions/linux-newbie-8/vi-and-emacs-33707/)

comptut 10-25-2002 06:26 AM

vi and emacs
 
need help with using vi or emacs. trying create a file in my home directory. use either emacs or vi to just write anything in the editor and save to the newly created file. i was under the impression that when i wanted to save the editor message i would write :w with the filename to be saved and the name of the directory to be saved in. i am apparently doing something incorrectly because i cannot get it to save. please help..

NSKL 10-25-2002 07:10 AM

With emacs:
^C-x ^C-w will save and exit emacs after modifying a buffer.
Try searching google for a emacs tutorial (or do the excellent one that comes with emacs already) and search fro a emacs reference card with all the common commands.
HTH
-NSKL

neo77777 10-25-2002 09:17 AM

How do you use vi to save the file to a specified location? Are you out of edit mode? Esc :w filename

neo77777 10-25-2002 09:21 AM

Also make sure you have write permissons to the directory you want your file to be saved in

adam_boz 10-26-2002 05:05 PM

I have a couple of files I use for reference on emacs and vi. here's what they say:

emacs:

**** "<C>" here means <ctrl>, "<M>" means "meta" or "Alt"

<C>-x <C>-f => "find" file, (open file)
<C>-g => universal "stop"-- good for when you mess up w/ commands
<esc><esc><esc> => same as <C>-g
<C>-x <C>-s => save file
<C>-x <C>-b => buffers list
<C>-x b => switch buffer
<C>-x a "#" => number of buffer windows
<C>-x o => move cursor to other buffer window
<C>-<M>-v => scroll other window
<C>-v => move foreward one screen
<M>-v => move back one screen
<C>-s => foreward search
<C>-r => reverse search
<F10> => pull down menu options... use arrows and <enter> to select

vim:

"i" => insert mode

"Esc" => normal mode

in insert mode, it's just like a normal text-editor.

some basic normal mode commands:

:q! => quit w/out saving
:w <file> => write to <file> (<file> only needed once)
:wq => write and quit
dw => delete word
d$ => delet to end of line
dd => delet whole line
u => undo command
<ctrl>-g => show location & status of file
:<command> => execute <command> (in bash... ex: mkdir)


Also, when you open up emacs, hit "ctrl-h t" for the tutor, and for vim, there's the "vimtutor" command (type from command line... not from inside vim)

jharris 10-26-2002 06:10 PM

I always specify the name of the new file on the command line when starting vi/emacs. That way I can just ESC :w or CTRL-x CTRL-s without needing to think about filenames again.

I opened this thread half expecting to see a holy war about Emacs vs Vi!

cheres

Jamie..

adam_boz 10-26-2002 06:30 PM

hehe... yeah me too. I've seen some really bloody battles out there on the subject.

I personally use vi if I am going to make some quick changes, and use emacs for anything more than that.

to each his own


All times are GMT -5. The time now is 12:06 PM.