Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

Emacs Tutorial
Emacs Getting In and Out
Emacs Minibuffer
Emacs Using Vi
Emacs Features
Emacs Polyglot
Emacs Help for the Translator
Emacs Bookmarks and Registers

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Using Vi in Emacs


Previoushome Next






Using Vi in Emacs


The two main commands are:


A D V E R T I S E M E N T

 

M-x vip-mode   change from emacs mode to vi mode
C-z            change from vi mode back to emacs mode

(Recall that there are also available viper-mode and vi-mode.) Both for convenience and for easy remembering, I have in my .emacs file (which you should copy, as mentioned earlier) these commands:

 

C-x v   change from emacs mode to vi mode
C-x e   change from vi mode back to emacs mode

Note that if there are two windows on a buffer, the vi commands work on the two windows as a whole; it is just one buffer, i.e. just one file. So, for instance, when I was searching for the string `WordCount' in the example above, I first typed

 

/WordCount

using the standard vi search command `/', and then moved to the other window and simply typed `n'. This is also a standard (though possibly new to you) vi command, meaning, ``Repeat the last search.'' So it did look for a string `WordCount', even though I had changed windows.

Just as ordinary vi will automatically read a file .exrc from your home directory, and read in customization commands from it, one can do this here too. In my .emacs file in my home directory, I have put the two lines

 

(local-set-key "]" 'vip-scroll)
(local-set-key "[" 'vip-scroll-back)

after the line

 

(vip-mode)

The latter line has emacs start up in vip-mode, and then the ``local'' commands apply to that mode. Whenever I am using vip-mode, the ] and [ keys will have the same meaning as vi's usual scroll-forward and scroll-backward commands, i.e. C-f and C-b.

 




Using Emacs for Compiling Programs


To compile a program whose source code you are editing in emacs, type

 

M-x compile

Since in a debugging session one will compile many times, to save typing, I have in my .emacs file bound C-x c to M-x compile, so I need type only C-x c.

Here is what happens when I type the compile command:

 

/* introductory C program */

/* implements (a subset of) the Unix wc command  --  reports character,
   word and line counts; in this version, the "file" is read from the
   standard input, since we have not covered C file manipulation yet,
   but of course a real file can be read by using the Unix `<' redirection
   feature */


#define MaxLine 200


char Line[MaxLine];  /* one line from the file */


int NChars = 0,  /* total number of characters in the file */
    NWords = 0,  /* total number of words in the file */
Compile command: make -k

Note the minibuffer here (`Compile command: make -k'). Though you can't see it here, the cursor is right after the -k. Emacs is waiting for me to confirm that this is the compile command which I want. I want a different one, so I use the Delete key (or Backspace key, on some terminals) to erase the `make -k', and then put in the compile command which I want, which in this instance is `cc -g WC.c': The screen now looks like this:

 

/* introductory C program */

/* implements (a subset of) the Unix wc command  --  reports character,
   word and line counts; in this version, the "file" is read from the
   standard input, since we have not covered C file manipulation yet,
   but of course a real file can be read by using the Unix `<' redirection
   feature */


#define MaxLine 200


char Line[MaxLine];  /* one line from the file */


int NChars = 0,  /* total number of characters in the file */
    NWords = 0,  /* total number of words in the file */
Compile command: cc -g WC.c

I then hit the return key, and emacs creates a new buffer for the compile:

 

/* introductory C program */

/* implements (a subset of) the Unix wc command  --  reports character,
   word and line counts; in this version, the "file" is read from the
   standard input, since we have not covered C file manipulation yet,
cd /usr/home/matloff/Courses/40/Progs/
cc -g WC.c








     
(No files need saving)

Eventually, that new buffer will include a `Compilation finished' message, and will display any syntax errors which it found. If there are any such errors, I can keep typing

 

C-x `

(C-x and then a backward apostrophe), and emacs will automatically go to the buffer for my source file, and position the cursor at the source of the error; this is a big convenience.

By the way, note the message `No files need saving'. If I had made a modification to the source file, emacs would have asked me if I wanted to save the file before compiling it.

I then invoke gdb. (Note: You probably will prefer to use ddd, a very nice graphical user interface for gdb. To do this in coordination with gdb, type "M-x gdb", then at the prompt change the command to "ddd --ttt --gdb". Be sure ddd is in your search path.) Emacs will ask me what the executable file name is, in this case a.out. Emacs will create a new buffer for gdb. Then I give gdb a breakpoint command, to stop at the function WordCount(), and I type r to run. When the program reaches the breakpoint, my screen looks like

 

Breakpoint 1 at 0x40023c: file WC.c, line 43.
(gdb) r < z
Starting program: /usr/home/matloff/Courses/40/Progs/a.out < z

Breakpoint 1, WordCount () at WC.c:43
(gdb)





int WordCount()

{  int I,NBlanks = 0;

=> for (I = 0; I < LineLength; I++)
      if (Line[I] == ' ') NBlanks++;

   /* ordinarily the number of words is NBlanks+1, except in the case
      in which the line is empty, i.e. consists only of the end-of-line
      character */

There are now two buffers displayed on the screen, my gdb buffer at the top and my WC.c buffer at the bottom. Note the marker `=>' in the latter; it shows that my next source-line statement is

 

for (I = 0; I < LineLength; I++)
   if (Line[I] == ' ') NBlanks++;

If for example I give gdb an n command now, it will execute that statement (and the `=>' marker will then advance to the next line).

Note again that if I want to restore the WC.c buffer to be displayed in full-screen instead of half-screen form, I merely need to type C-x o to switch to the WC.c buffer, and then type C-x 1.



Be the first one to comment on this page.




  Emacs Tutorial eBooks

No eBooks on Emacs could be found as of now.

 
 Emacs Tutorial FAQs
More Links » »
 
 Emacs Tutorial Interview Questions
More Links » »
 
 Emacs Tutorial Articles

No Emacs Articles could be found as of now.

 
 Emacs Tutorial News

No News on Emacs could be found as of now.

 
 Emacs Tutorial Jobs

No Emacs Articles could be found as of now.


Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: Using Vi in Emacs, Emacs, Emacs, Emacs tutorial, Emacs tutorial pdf, history of Emacs, Custamizing Style Sheet, learn Emacs

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.