Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » I've Switched To Spaces

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
I've Switched To Spaces
bamccaig
Member #7,536
July 2006
avatar

I used to always prefer tabs for indentation, but after struggling with alignment for so long and also learning a bit of Python, which benefits from spaces, I've decided to switch completely over to spaces.

Now we can have another tabs vs. spaces flame war, but now I've switched sides... :P

** EDIT **

I'm so used to Tab meaning a tab character that I keep instinctively using the Space bar to indent now... :-X

Thomas Fjellstrom
Member #476
June 2000
avatar

I press tab for indent. regardless of what it means in any given project (my projects tend to use literal tabs, displayed at 3 spaces).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

I've configured Vim to use spaces to indent, but I just instinctively hit the Space bar 4 times instead of tab... It's starting to make me struggle at j0rb too cause they use tabs there (and they probably haven't reached a point yet where spaces make sense), but I'm starting to get used to using spaces. My environments have always been configured to use tabs, so whenever I used to use spaces to indent (mainly here on Allegro.cc and I suppose recently in Python) I would do so manually with the Space bar; so I started doing that at j0rb the past couple of days. Once I get used to using the tab key for spaces for my own stuff, it should be less of a problem because it should just work most of the time at j0rb (cause it's configured for tabs there) the same as it does at home (which will be configured for spaces). The difference should often be transparent.

ReyBrujo
Moderator
January 2001
avatar

I use tab, but let Vim translate those to spaces. I simply detest tab, especially when people use some "odd" tabulation (like 3 spaces, so they combine tab and spaces when having more than 2 or 3 indentation levels).

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

DanielH
Member #934
January 2001
avatar

Since the dawn of time...

I've been programming for a long time now and have always used spaces. Recently, a couple of months, I switched to tabs to see how I would feel. I like tabs better.

Thomas Fjellstrom
Member #476
June 2000
avatar

I haven't seen a decent editor that would let you move properly through text when spaces are used for indentation, so I try not to use them. Its annoying. Have to press the arrow key for each space. Thats how people get carpal-tunnel for peat's sake.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

ReyBrujo
Moderator
January 2001
avatar

Well, if you are not going to make puns, Vim lets you move to the first non blank character of the line (similar to what some Microsoft IDEs do when you press Home, you go to the first non blank character instead of the start of the line). Most editors let you skip all the blanks with CTRL+LEFT, for example.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Shravan
Member #10,724
February 2009
avatar

I would use spaces between the words of a program and tabs whenever a new block begins.Tabs increase the readability of the code.

Peter Wang
Member #23
April 2000

I haven't seen a decent editor that would let you move properly through text when spaces are used for indentation, so I try not to use them. Its annoying. Have to press the arrow key for each space. Thats how people get carpal-tunnel for peat's sake.

Right, don't do that. As Rey says, skip entire words at a time. But I wonder why you need to be cursoring over indentation anyway. Every editor I've ever used (except maybe notepad) at least lets you jump to the start of the line past the indentation, if it doesn't place you there already.

Another vi/vim tip to avoid cursoring (and this is one I didn't know for a long time): the 'f' command lets you skip directly to the next occurrence of a character on the line, e.g. f, skips to the next comma. 'F' goes in the other direction.

Thomas Fjellstrom
Member #476
June 2000
avatar

Right, don't do that. As Rey says, skip entire words at a time. But I wonder why you need to be cursoring over indentation anyway. Every editor I've ever used (except maybe notepad) at least lets you jump to the start of the line past the indentation, if it doesn't place you there already.

Modifying indentation for one. CTRL+LEFT is rather hard to press on my laptop, and it goes up to the next line, I rarely want that. I'm trying to navigate around the beginning of the line. If I wanted to navigate to the prior line, I'd press up and maybe end, not CTRL+LEFT a bunch of times.

Also, if you set your editor to display whitespace, all those little dots in the indentation gets to be quite distracting. I'd prefer one per indentation level (which is what a hard tab gives you), not one per space ::) (which is what space indentation gives you).

Also, I don't use any variant of vi or emacs. Too much a pain in the ass. And yes I tried learning it. Didn't find it worth the effort. I like a good gui editor that blends into my desktop. Not some console editor (except nano for quick ssh editing), or some hacked up mashup (aka gvim). I just don't like either editor very much.

Now those aren't the only reasons I've found I had to cursor over the leading white space, just all I could think of at the moment.

Also, "Right don't do that" is not a solution. I'm tired of people providing that as a solution to things, that really do have a valid alternative.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Peter Wang
Member #23
April 2000

Just trying to save some wrists.

Martin Kalbfuß
Member #9,131
October 2007
avatar

Classic tabs with a length of 8 spaces.
I let gedit show me tabs and spaces. This way I can see my mistakes. This works well for python, too. If you don't like how it looks. You can switch it on, only if you want to check your indentation.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Thomas Harte
Member #33
April 2000
avatar

Nothing but tabs for me, same as I wouldn't use two hyphens to make an emdash. Actually, scratch that comparison - I've never understood why anyone thinks this decision is anything other than personal preference.

And, yes, it does make me feel bad when I post from my iPhone like now and the only dash easily available is a plain hyphen.

Evert
Member #794
November 2000
avatar

Modifying indentation for one.

Well. Any one of <<, == or >> in vim will do that for me (which to use depends on what exactly I need to correct). For entire blocks =i} or =i{ does very well too.

Quote:

Also, I don't use any variant of vi or emacs. Too much a pain in the ass. And yes I tried learning it. Didn't find it worth the effort.

To each his own. Learning to use vim somewhat properly has probably been the most useful time investment I've ever made when it comes to using a computer (probably comparable to learning Perl - between Perl and vim I'm not sure how I managed to use a computer before).

Quote:

I like a good gui editor that blends into my desktop.

Personally I like a good editor. :P

Quote:

Not some console editor (except nano for quick ssh editing), or some hacked up mashup (aka gvim).

Huh? To what specifically are you referring?

Quote:

Also, "Right don't do that" is not a solution. I'm tired of people providing that as a solution to things, that really do have a valid alternative.

Well, you said "I haven't seen a decent editor that would let you move properly through text when spaces are used for indentation". Vim lets you do exactly that.

james_lohr
Member #1,947
February 2002

I used to use spaces in old crappy IDEs, but I use tabs now since most modern IDEs are intelligent enough to allow spaces and tabs to be used interchangeably with minimal hassle.

bamccaig
Member #7,536
July 2006
avatar

I haven't quite learned to properly navigate through the text in Vim, but I have seen it demonstrated just how easy it is if you know how. It's so much faster to do anything than in a conventional editor. That's why I stick to Vim whenever I can. I'm slowly trying to learn how to use it properly... It would be nice to take an actual course in it actually, but otherwise finding the time to run through decent tutorials should be fine.

Thomas Harte
Member #33
April 2000
avatar

Yes, I think the last time I deliberately used spaces was back in ye olde days of RHide.

EDIT: that Jef Raskin(-inspired?) editor has the fastest text navigation I've ever used. Hold down a modifier and type, the editor jumps to the next instance of that text. Hold down an alternative modifier and it'll search for the previous instance.

Timorg
Member #2,028
March 2002

I prefer 4 spaces for tabs, and in the editor (Code::Blocks) they act as spaces, but when the file is saved they are converted to tabs. That way if I edit the file with Vim it still works out ok.

____________________________________________________________________________________________
"c is much better than c++ if you don't need OOP simply because it's smaller and requires less load time." - alethiophile
OMG my sides are hurting from laughing so hard... :D

ReyBrujo
Moderator
January 2001
avatar

Classic tabs with a length of 8 spaces.

8 spaces is too large for me. 3 is odd, so I prefer 4.

Hold down a modifier and type, the editor jumps to the next instance of that text. Hold down an alternative modifier and it'll search for the previous instance.

You use / to search forward in Vim, and ? to search backwards. Even Firefox uses / for quick search.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Sirocco
Member #88
April 2000
avatar

I love the TAB key. What I love most is that when I press it, four spaces are inserted into my code instead. Fuck yeah.

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Thomas Harte
Member #33
April 2000
avatar

ReyBrujo said:

You use / to search forward in Vim, and ? to search backwards

That's modal rather than quasimodal, which means that it takes more mental processing to make reflexive. Modal = need to keep more in your mind at once.

Essentially though, it's nice that bamccaig and I agree, even if I didn't realise it.

EDIT: I guess it's like the difference between CAPS LOCK and using the shift key. Except for a feature that you probably use much less frequently.

Indeterminatus
Member #737
November 2000
avatar

Use code formatting tools. Focus your worries on something else (meaning, more important).

\o/

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

bamccaig
Member #7,536
July 2006
avatar

Ooh, I've just discovered tagging in Vim! \o/ Generate a tags file with ctags (not sure if it only supports C or if it has support for other languages... Maybe there are similar commands for other languages).

[bamccaig@rufus trunk]$ ctags `find -name \*.h -o -name \*.c`
[bamccaig@rufus trunk]$ vim tests/bam_list_test/src/main.c

From within Vim:

:tag bam_list_create

Vim automatically finds the definition of bam_list_create in src/bam_list.c (technically it just matches it in the tags file) and opens it. ;D

** EDIT **

[bamccaig@rufus trunk]$ ctags --list-languages
Asm
Asp
Awk
Basic
BETA
C
C++
C#
Cobol
Eiffel
Erlang
Fortran
HTML
Java
JavaScript
Lisp
Lua
Make
Pascal
Perl
PHP
Python
REXX
Ruby
Scheme
Sh
SLang
SML
SQL
Tcl
Vera
Verilog
Vim
YACC
[bamccaig@rufus trunk]$ 

Nvm. ;D

Thomas Fjellstrom
Member #476
June 2000
avatar

I really don't know why people continue to give vim examples to me. I don't use it, and likely never will :P

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Thomas Harte
Member #33
April 2000
avatar

That example at least undercuts anyone who might assume that text based software is inherently less featured. Though I doubt anyone here would. You know, other than making general observations about the correlations between launch date and probability of software being text based and between launch date and the probability of software having <arbitrary feature>.

 1   2   3 


Go to: