Administration
  Home arrow Administration arrow Page 7 - Vi 201
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ADMINISTRATION

Vi 201
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2000-05-11


    Table of Contents:
  • Vi 201
  • Liar, Liar...
  • Re-thinking Relativity
  • Sweet Revenge
  • The Shell Game
  • First Aid 101
  • An Indent In Time...
  • Exit Flootburger

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Vi 201 - An Indent In Time...
    ( Page 7 of 8 )

    Finally, if you're a programmer, vi comes with a number of features that you should find useful. Here are some tips that might help you the next time you sit down to code The Next Big Thing.

    1. Let vi indent your code for you. Try

    :set autoindent
    and watch as vi automatically indents nested blocks of code like loops and conditional statements. C programmers might also like to take a look at

    :set cindent
    which offers some additional indenting styles.

    2. In case you forget to turn auto-indenting on, all is not lost. Simply select the lines of code you wish to indent, and hit

    =
    Vi will do its best to indent the code correctly for you.

    To illustrate the power of this trick, here's a "before" picture:

    if(time == 13) { lunch(); } else if (time == 22) { if (day == "Friday") { echo "Apple pie for dessert!": } else { echo "Oh no, not lasagna again!"; } }
    and here's the "after" picture:

    if(time == 13) { lunch(); } else if (time == 22) { if (day == "Friday") { echo "Apple pie for dessert!": } else { echo "Oh no, not lasagna again!"; } }
    3. Newer versions of vi comes with "syntax highlighting" - the ability to highlight program code in different colours. To turn this feature on, simply type

    :syntax on
    while

    :syntax off
    will turn it off.

    Vi currently supports most popular programming languages - your distribution should come with syntax files for C, C++, HTML, Java, Perl, PHP and other common languages.

    4. Vi also comes with the very useful "ctags" program, which can be used to create an index of classes, function definitions, variable declarations and methods for C, C++ and Java source code. This index, also known as a "tag" list, can be used by vi and other text editors to assist you in quickly locating sections of your source code while programming.

    To use vi's tag features, it's first necessary to create a tag file - simply change to the directory containing your source code and run the "ctags" program on the files you wish to index, like this:

    $ ctags *.c
    You should now have a file named "tags" in that directory.

    Now open one of your C files, and scroll down until you locate a function call. Position the cursor over that function call, and hit

    ^-] [that's Ctrl-square-brace]
    Vi will automatically load the file containing the function definition, and display it to you. To go back to the original file, use

    ^-T [that's Ctrl-T]
    This comes in very handy when your code is scattered across multiple files, and you just can't remember what the function popeye_loves_spinach() does.

    This article copyright Melonfire 2000. All rights reserved.

     
     
    >>> More Administration Articles          >>> More By Vikram Vaswani, (c) Melonfire
     

       

    ADMINISTRATION ARTICLES

    - Network Booting via PXE: the Basics
    - Scalix: Linux Administrator`s Guide
    - Network Administration with FreeBSD 7
    - Components of an Information Architecture
    - The Anatomy of an Information Architecture
    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek