help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Vim, using tabs, using spaces


From: Paul Laub
Subject: Re: Using Vim, using tabs, using spaces
Date: Sat, 19 Feb 2005 23:16:45 -0800

Steve, 

I write all of my code, and a lot more, in vim. It's a fine editor.
Vi, but not Emacs, was on the Sun workstation that I learned Unix on
back in 1989. Thus my fate was set.

I avoid the tab character because you never know how a printer will
expand it. Plus, old Fortran 77 compilers can get messed up by the tab
character too.

In vim, you can use these settings --

set expandtab
set tabstop=N
set shiftwidth=N

to expand a press of the tab key to N whitespaces. I prefer N=4, but
that's me. Put those settings in your .vimrc file.

Also, there is an old C program called indent.c that allows you to
transform C source code, maybe C++ too, from any indentation style to
any other style. That program has probably saved us from many flame
wars.

Paul Laub 


On Sat, 19 Feb 2005 22:21:05 -0800, Steve C. Thompson <address@hidden> wrote:
> Group,
> 
> This leads me to the next question.
> 
> The last post I made came back looking like ass.  The tabs in Vim looked
> fine on my computer. Do you guys use Vim to write your Octave code (I
> have the feeling that JWE prefers Emacs).  Is tabbing good practice or
> using spaces?  From my experience, tabbing can get you into trouble --
> the previous post is a case in point.
> 
> Below is the program with spaces.
> 
> --------------------------------------------
> 
> #include <octave/oct.h>
> #define PI 3.14159265358979
> DEFUN_DLD (sct_complex_matrix, args, , "Returns a complex matrix")
> {
>   octave_value retval;
>   int subcarrier_number = 128;
>   int oversample_factor = 4;
>   int sample_per_block = subcarrier_number * oversample_factor;
>   ComplexMatrix subcarrier_matrix(
>     subcarrier_number,
>     sample_per_block );
>   for (int n = 0 ; n < sample_per_block ; n++)
>   {
>     for (int k = 0 ; k < subcarrier_number ; k++)
>     {
>       subcarrier_matrix(n,k)=Complex(
>         cos( 2 * PI * n * k / subcarrier_number),
>         sin( 2 * PI * n * k / subcarrier_number) );
>     }
>   }
>   return retval = subcarrier_matrix;
> }
> 
> --------------------------------------------
> 
> Now with tabbing.
> 
> --------------------------------------------
> 
> #include <octave/oct.h>
> #define PI 3.14159265358979
> DEFUN_DLD (sct_complex_matrix, args, , "Returns a complex matrix")
> {
>         octave_value retval;
>         int subcarrier_number = 128;
>         int oversample_factor = 4;
>         int sample_per_block = subcarrier_number * oversample_factor;
>         ComplexMatrix subcarrier_matrix(
>                         subcarrier_number,
>                         sample_per_block );
>         for (int n = 0 ; n < sample_per_block ; n++)
>   {
>                 for (int k = 0 ; k < subcarrier_number ; k++)
>                 {
>                         subcarrier_matrix(n,k)=
>                                 Complex(
>                                                 cos( 2 * PI * n * k / 
> subcarrier_number),
>                                                 sin( 2 * PI * n * k / 
> subcarrier_number) );
>                 }
>         }
>         return retval = subcarrier_matrix;
> }
> 
> --------------------------------------------
> 
> Thanks,
> Steve
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
>



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]