Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 192010
 

Code formatting and indentation in VIM

Answer:

Vim support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by setting the filetype)

e.g. A simple C program (test.c)


#include 

main()
{
for(int i=0;i<10;i++)
{ 
printf ("Hello World!\n");
}
}

Then type following in Vim command mode (by pressing Esc):

gg=G

Now the code will be formatted to:

#include 

main()
{
    for(int i=0;i<10;i++)
    {
        printf ("Hello World!\n");
    }
}
Aug 302010
 

Fix the warning of: Remote Host Identification Has Changed error and solution

Answer:

You might experience this error, especially when you are connecting to a remote Linux machine which has just got re-installed.

To solve this, enter the command:

# ssh-keygen -R 192.168.2.36

Where 192.168.2.36 is the IP you are connecting.

Aug 092010
 

Mirror a web site using wget

Answer:

wget is a standard program came with most Linux distributions. It allows you to create a mirror (backup) of a web site easily using the following command.

# wget -m -k -K -E http://www.example.com