Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

31.3.1 Basic Program Indentation Commands

The basic indentation commands indent a single line according to the usual conventions of the language you are editing.

<TAB>
Adjust indentation of current line.
C-j
Equivalent to <RET> followed by <TAB> (newline-and-indent).
<LINEFEED>
This key, if the keyboard has it, is another way to enter C-j.

The basic indentation command is <TAB>, which gives the current line the correct indentation as determined from the previous lines. The function that <TAB> runs depends on the major mode; it is lisp-indent-line in Lisp mode, c-indent-command in C mode, etc. These functions understand the syntax and conventions of different languages, but they all do conceptually the same job: <TAB> in any programming-language major mode inserts or deletes whitespace at the beginning of the current line, independent of where point is in the line. If point was inside the whitespace at the beginning of the line, <TAB> puts it at the end of that whitespace; otherwise, <TAB> keeps point fixed with respect to the characters around it.

Use C-q <TAB> to insert a tab character at point.

When entering lines of new code, use C-j (newline-and-indent), which is equivalent to a <RET> followed by a <TAB>. C-j at the end of a line creates a blank line and then gives it the appropriate indentation.

<TAB> indents a line that starts within a parenthetical grouping under the preceding line within the grouping, or the text after the parenthesis. Therefore, if you manually give one of these lines a nonstandard indentation, the lines below will tend to follow it. This behavior is convenient in cases where you have overridden the standard result of <TAB> because you find it unaesthetic for a particular line.

By default, an open-parenthesis, open-brace or other opening delimiter at the left margin is assumed by Emacs (including the indentation routines) to be the start of a function. This speeds up indentation commands. If you will be editing text which contains opening delimiters in column zero that aren't the beginning of a functions, even inside strings or comments, you must set open-paren-in-column-0-is-defun-start. See Left Margin Paren, for more information on this.

Normally, lines are indented with tabs and spaces. If you want Emacs to use spaces only, see Just Spaces.


 
 
  Published under the terms of the GNU General Public License Design by Interspire