Library Technology – Reviews, Tips, Giveaways, Freeware

Linux tips: Using Emacs – Part I

Posted In Linux - By Techtiplib on Tuesday, June 12th, 2012 With No Comments »

This series ‘Using Emacs’ shall explain how to make effective use of Emacs. There are books that are about 1k pages thick that teach you to use Emacs.They not only cost a lot but also overwhelm you with unnecessary capabilites of Emacs (atleast for newbies).

So what I shall be doing is explain the various features of Emacs as I learn them myself. This is the first posting in this series. Since I am writing these postings as I learn Emacs, these tips would be in the order that a newbie would want these to be.. since I too started with no knowledge. So go ahead and read the other articles in this series ‘Using Emacs’ as and when they are put up on the site.

IMPORTANT: The notation used for the various keystrokes are as decribed below. Use this table to figure out what to press in case you cant figure out the notation used in any of the articles in this series.

<Ctrl>-Y This means press Ctrl button and without leaving that button press Y button
<Ctrl>-YK This means press Ctrl button and then without leaving that button press Y button and leave Y button and then press the K button. (Remember Ctrl has to be pressed throughout)
<Ctrl>-K + K This means press Ctrl button and then without leaving that button press K button. Then leave both these buttons and then press the K button.

Here begins (what I guess shall be..) the never ending list of Emacs tips..

Tip No. 1 : Opening a File

Use <Ctrl>-XF. This would prompt for a file name with the prompt already pointing towards your Home directory. You can delete the default entry and type any new location. Remember to enter the complete filename including the extension else Emacs will create a new file (buffer) with that name. Once you have typed the name of the file press <Enter>.

Tip No. 2 : Exiting Emacs

Use <Ctrl>-XC. This would exit Emacs and get you back to your shell prompt. In case there are modified files (buffers) , you would be prompted whether you want to save the changes or discard the changes. Type as requested. The options are clearly specified at the bottom when the questions are asked so it should not be a problem.

Tip No. 3 : Saving a File

Use <Ctrl>-XS. This would save the file that is currently highlighted. I mean the file in which your cursor is currently present.

Tip No. 4 : Viewing currently open files (buffers)

Use <Ctrl>-XB. This would open a new window which have around with 3-4 entries (by default). This window would have a list of all the buffers that are currently open. You would have to shift focus to this new window in order to modify anything within the window. Use <Ctrl>-XO as many times to shift focus and come to the buffers window. To view any of the buffers listed simply move cursor to that buffer and press <Enter>.

Tip No. 5 : Moving to the beginning and end of a line

Use <Ctrl>-A to go to the beginning of a line and use <Ctrl>-E to go to the end of a line.

Tip No. 6 : Moving Character wise to the right and left

Use <Ctrl>-F and <Ctrl>-B to move to the right and left respectively. Remember F stands for Forward and B for Backwards.

Tip No. 7 : Moving Word wise to the right and left

Use <Alt>-F and <Alt>-B to move one word to the right and left respectively. Remember once again F stands for Forward and B for Backwards.

Tip No. 8 : Moving Line wise up and down

Use <Ctrl>-P and <Ctrl>-N to move one line up and down respectively.

Tip No. 9 : Moving Page wise up and down

Use <Alt>-V and <Ctrl>-V to move one page up and down respectively.

Tip No. 10 : Closing a File (buffer)

Use <Ctrl>-X+K. This would prompt you for a buffer name. You have to type the exact buffer name and then press <Enter>. This would close the buffer or ask you to save any changes made to the buffer before closing the buffer.

Tip No. 11 : Delete Text (Letters)

Use <Del> button to delete letters. You could also use <Alt>-<Del> if required.

Tip No. 12 : Kill Text / Cut Text (Lines)

Use <Ctrl>-K. This would kill / cut the text from the cursor position to the end of the line. Hence if you want to kill an entire line its a good practice to memorize the sequence <Ctrl>-A <Ctrl>-K which would move the cursor to the beginning of the line and then kill the entire line.

Tip No. 13 : Yank Text / Paste Text (Lines)

Use <Ctrl>-Y. This would yank / paste the text that was most recently killed. Use <Alt>-Y to yank more text that was killed.

Tip No. 14 : Kill / Cut a Region of Text

Use <Ctrl>-<Space> to mark the starting position of the region you want to kill. Then go to the end of the region and press <Ctrl>-W. This would kill the entire region. You could then go to the new position and yank this entire killed region using <Ctrl>-Y as usual.

Read the other articles in this series ‘Using Emacs’ for more useful tips. There are a lot of tips regarding cursor movements which I have not listed here. Since those key combinations would only leave you confused since you wouldn’t be using most of them as a newbie. So those key combinations would be introduced in the later articles in this series.

As I mentioned before if you learn Emacs in the sequence that is present in this series, I am sure you would be able to complete most of your tasks since I wrote these articles as I was learning Emacs. Hence whatever a newbie would require would be present in the initial articles in this series and the experts could use the later sections.

Source: codecoffee.com

More contents in: , ,

About -

Hey, this blog belongs to me! I am the founder of TechTipLib and managing editor right now. And I love to hear what do you think about this article, leave comment below! Thank you so much…