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
Evert
Member #794
November 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

Probably because you complain about editors not being able to do such and so while vim can do such and so easily. ;)

gnolam
Member #2,030
March 2002
avatar

quasimodal

An interface making extensive use of \a?

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Thomas Harte
Member #33
April 2000
avatar

gnolam said:

An interface making extensive use of \a?

Not so much using it as just going on about it tediously. Never invite a quasimodal interface to a dinner party.

Thomas Fjellstrom
Member #476
June 2000
avatar

Evert said:

Probably because you complain about editors not being able to do such and so while vim can do such and so easily. ;)

I didn't say editors couldn't modify indentation ::) I said thats one reason I move around in leading white space.

Even kate has a short cut for modifying indentation. I can never remember all of the extra shortcuts though (one reason why vi/emacs would be USELESS for me), so I tend to just do things manually.

--
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

bamccaig said:

Ooh, I've just discovered tagging in Vim!

It is kind of obsolete now that Vim features native intellisense, but it is still pretty powerful.

By the way, I thought you were talking about marks (using m[a-zA-Z] to mark a position in the file, then '[a-zA-Z] to go to the mark).

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

bamccaig
Member #7,536
July 2006
avatar

ReyBrujo said:

It is kind of obsolete now that Vim features native intellisense, but it is still pretty powerful.

Yeah, but I haven't gotten that far yet. :P Besides, even in Visual Studio I find myself using the "Go To Definition" feature relatively often.

You wouldn't happen to know the relevant commands/configuration settings, or even better a tutorial or reference, for getting intellisense configured in Vim?

** EDIT **

Making some progress, maybe. While in insert mode, press CTRL-X to enter CTRL-X mode where it seems the insert completion functionality is. More can be found with :h ins_completion.

ReyBrujo
Moderator
January 2001
avatar

If you have set your paths correctly (set path=/usr/include,.,../include or similar, so that they include all your headers) you can use [i to see the declaration of a variable, and CTRL-W i to go to the declaration in a new window with the original Vim parsing (without the tags).

Now that you already got tagging working, add set tags=~/.vim/stdtags,./tags,../tags,tags to your vimrc file, then create the tags, putting the tag file in one of the previously mentioned positions (for example, ./tags or ../tags). Then in the vimrc add autocmd FileType c set omnifunc=ccomplete#Complete to bind the file type with the omnifunction to use. Finally, just declare an object and try to access its members, if you are using gvim a popup will appear with the members.

Omni requires ctags to work (adding all the ctags code into the Vim executable would be a waste of time). However, it natively supports CSS and other types. Check :help ft-c-omni for more information.

(Edited: Maybe this old guide helps you?)

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

bamccaig
Member #7,536
July 2006
avatar

[bamccaig@rufus ~]$ du -h ~/.vim/systags 
702M	/home/bamccaig/.vim/systags
[bamccaig@rufus ~]$ 

What do I do about this? :'( I hit i CTRL-X CTRL-O and Vim locked up the entire system. :P

Thomas Fjellstrom
Member #476
June 2000
avatar

You probably have a shit load of dev packages installed :D

--
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 removed ~/.vim/systags from the list for now because clearly it's unreasonably large. I just tried to open project specific intellisense though and I get "unknown function ccomplete"... :( Something is clearly wrong and I'm too tired to figure it out right now.

ReyBrujo
Moderator
January 2001
avatar

Do a <i>du -h usr/include to weight the directory. I got around 50mb, which generates a 75mb systags file. You probably passed too many arguments to ctags, generating a lot of information (that may not be necessary).

(Edited:

bamccaig said:

I just tried to open project specific intellisense though and I get "unknown function ccomplete"

Which version are you using? It looks you are missing ccomplete.vim. Try locate ccomplete to see if you have it somewhere, I had it at /usr/share/vim/vim72/autoload/ccomplete.vim.)

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

bamccaig
Member #7,536
July 2006
avatar

ReyBrujo said:

Do a du -h usr/include to weight the directory. I got around 50mb, which generates a 75mb systags file. You probably passed too many arguments to ctags, generating a lot of information (that may not be necessary).

148M.

ReyBrujo said:

Which version are you using? It looks you are missing ccomplete.vim. Try locate ccomplete to see if you have it somewhere, I had it at /usr/share/vim/vim72/autoload/ccomplete.vim.)

Same.

BAF
Member #2,981
December 2002
avatar

Guh, I simply do not understand the use of spaces for indenting. At all. Any proper editor should be able to emulate spaces/set whatever spacing you want/etc for tabs. Using spaces forces your shitty indentation styles on others, makes file sizes larger (negligible though), etc. And if python benefits from using spaces vs. tabs, then it's a shitty language.

ReyBrujo
Moderator
January 2001
avatar

Quote:

148M.

Then yeah, it is possible. Maybe you can only parse the directories you want (say, don't go into subdirectories you don't need).

bamccaig said:

Same.

What are the contents of your vimrc?

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

bamccaig
Member #7,536
July 2006
avatar

BAF said:

Guh, I simply do not understand the use of spaces for indenting. At all. Any proper editor should be able to emulate spaces/set whatever spacing you want/etc for tabs. Using spaces forces your shitty indentation styles on others, makes file sizes larger (negligible though), etc.

Technically, there's no reason a powerful editor couldn't also switch between space-based indentation. You should be able to say "This file was created with 4-space based indentation. Convert them to tabs."

I used to agree with tabs (and really the difference in indentation width sort of scares me about using spaces, though it should still be convertible most of the time), but I have just found tabs to be disorganized when it comes to alignment. Sure, you can use tabs to indent and spaces to align, but in practice I've found it insufficient. I'm hoping spaces corrects that problem. I don't dislike tabs, but I'm hoping moving to entirely spaces will be more organized and portable.

BAF said:

And if python benefits from using spaces vs. tabs, then it's a shitty language.

I don't even remember why spaces are recommended (though not required) for indentation in Python, but I remember accepting it as best practice. The interpreter even has command-line arguments to warn (-t) or even error (-tt) when tabs are used for indentation. Python is by no means my favorite language, though I appreciate its differences.

ReyBrujo said:

What are the contents of your vimrc?

[bamccaig@rufus trunk]$ cat ~/.vimrc
:set autoindent
:set expandtab
:set hidden
:set ignorecase
:set nowrap
:set number
:set ruler
:set shiftwidth=4
:set softtabstop=4
:set tabstop=4
":set tags+=~/.vim/systags,~/.vim/tags,../tags,./tags
:set tags+=../tags,./tags

:autocmd FileType c set omnifunc=ccomplete
:autocmd FileType cpp set omnifunc=cppcomplete
:autocmd FileType cs set omnifunc=cscomplete
:autocmd FileType css set omnifunc=csscomplete
:autocmd FileType d set omnifunc=dcomplete
:autocmd FileType javascript set omnifunc=javascriptcomplete
:autocmd FileType php set omnifunc=phpcomplete
:autocmd FileType python set omnifunc=pythoncomplete
:autocmd FileType xml set omnifunc=xmlcomplete
:autocmd FileType xsl set omnifunc=xslcomplete

"set term=ansi
"set term=color_xterm
syntax on

:colorscheme bam
":colorscheme bam-dark
[bamccaig@rufus trunk]$ 

(As you can see I may have gotten carried away with the omnifunc bits... :P Most of which I'm unsure about their correctness...)

deps
Member #3,858
September 2003
avatar

I use TextMate and two spaces. Never tabs.

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

Neil Walker
Member #210
April 2000
avatar

I see using spaces as only of relevant if the position of text in columns is important, such as tabular data. But for coding, I couldn't care less if tab is 4 characters on one computer and 8 on the other - you can still see the code layout as it was intended.

Or think of it in this way: If you use tab then you can set your preferred viewing method. If you use spaces that's all you get.

I think the pattern emerging here is those using modern IDE's use tab, and those using text based unix editors prefer spaces.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

GullRaDriel
Member #3,861
September 2003
avatar

It's a lost cause. It'll always end in a war thread, between those who only think in space, and those who only thrust tabs.

My point of view on that subject is that it doesn't matter. Space and tabs are mostly ignored during compilation, and when you program something for your enterprise, only the result matters. They'll never look at your code, even if it crash.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

bamccaig
Member #7,536
July 2006
avatar

Or think of it in this way: If you use tab then you can set your preferred viewing method. If you use spaces that's all you get.

While I agree with you for simple indentation, when it comes to alignment things get a little bit more complicated. Since most people have their editors configured to not show whitespace, it isn't obvious when you accidentally tab code into alignment.

--->--->really_long_function_name1(really_long_argument1,
--->--->--->                       really_long_argument2);
//      ^ Oops, that should be 4 spaces instead of a tab, but with invisible
//        whitespace you wouldn't notice.

When that code is opened in an editor whose tabstop isn't 4 the code won't line up properly anymore. It's not a show stopper (I don't have any really useful examples to show right now), but if you're obsessive about formatting like I am it's frustrating fighting with it. There's also the fact that tabs typically display as 8 characters wide in text terminals so if you spend a lot of time in them (and you should ;)) then you'll also find that spaces work better for things printed to the terminal.

I also find myself fighting with indentation in JavaScript, where I often use lots of JSON and getting it to line up properly with tabs and spaces combined is often a struggle.

I think the pattern emerging here is those using modern IDE's use tab, and those using text based unix editors prefer spaces.

I use both (I develop with Visual Studio at j0rb), but I prefer working in text terminals. Even at work though (as I said, with JavaScript, for example) I still struggle to keep alignment right.

Thomas Harte
Member #33
April 2000
avatar

It's a lost cause. It'll always end in a war thread, between those who only think in space, and those who only thrust tabs.

My point of view on that subject is that it doesn't matter.

But how do you feel about Hungarian Notation? Or, ummmm, Windows versus Mac? Z80 or 6502? Coke or Pepsi? Jalapenoes or chillis? Winston or Salem? Marmite or absolutely any other spread?

EDIT:

bamccaig said:

if you're obsessive about formatting like I am it's frustrating fighting with it

My only obsession, which I've been trying desperately to fight for years, is that I hate otherwise completely empty lines that have white space on them. One of my standard brain unengaged tasks when I'm thinking about a real problem is to go through source files and kill them by hand. I don't know why.

bamccaig
Member #7,536
July 2006
avatar

My only obsession, which I've been trying desperately to fight for years, is that I hate otherwise completely empty lines that have white space on them. One of my standard brain unengaged tasks when I'm thinking about a real problem is to go through source files and kill them by hand. I don't know why.

Yeah, that bothers me too. Another gripe is trailing whitespace. Fortunately, with a powerful editor it's relatively easy to get rid of both automatically.

:%s/\s\+$//g

Obviously not unique to Vim, though I would say that of the editors that I use regularly it's easiest to do in Vim. I think Visual Studio used to do this automatically, but recent iterations don't seem to have that feature by default anymore.

Thomas Harte
Member #33
April 2000
avatar

bamccaig said:

Fortunately, with a powerful editor it's relatively easy to get rid of both automatically.

Yeah, I know. But I like to occupy myself with a mindless task when I'm trying to think, so I prefer to do it myself. Or, at least, leave it to be done when next I have an actually hard problem rather than the routine nothingness that is 95% of all programming. In any language.

bamccaig
Member #7,536
July 2006
avatar

Mmmmmz, automatic. :P

func! DeleteTrailingWS()
  exe "normal mz"
  %s/\s\+$//ge
  exe "normal `z"
endfunc

autocmd BufWrite * :call DeleteTrailingWS()

[1]

ReyBrujo
Moderator
January 2001
avatar

My only obsession, which I've been trying desperately to fight for years, is that I hate otherwise completely empty lines that have white space on them.

My only one is deleting the lonely { after opening a block or function. Poor {, don't you see it is sad there alone?

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

Thomas Harte
Member #33
April 2000
avatar

So you prefer:

if(a){

to:

if(a)
{

then? Because you know you shouldn't just delete the opening curly braces?

 1   2   3 


Go to: