Best IDE for OSDev / Cross Compiling

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: Best IDE for OSDev / Cross Compiling

Post by rdos »

Kevin wrote:So what are the configuration changes that both of you made?

I just checked my config and there isn't much special stuff in it. The only big thing is cscope integration (which I consider essential), and then there are smaller useful things like highlighting trailing whitespace or anything > 80 characters in a source file, enabling FPC extensions for Pascal syntax highlighting etc. I tried things like omnicppcomplete because everyone keeps saying that you absolutely need some context-sensitive autocompletion, but to be honest I found it to be more annoying than helpful. So I'm back to Ctrl-P for now.
When we are on the subject, does anybody know a decent "indention-fixer" that does NOT change the code in any way (like removing / adding { or }), but fixes the code so indention is alwayws a multiple of 4 spaces, and that replaces TABs with spaces? Some of my sorce-files have become a mixture of 4 and 8 space indentions (some of my tools incorrectly replace TAB with 8 spaces). I used some Linux-based tool years ago, but it broke my code as it tried to add / remove {} as well, which was no hit.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Solar »

VIM.

Code: Select all

:set listchars=tab:>-,trail:·
:set list
Makes shift vs. tab visible. (Trailing spaces, too...)

Code: Select all

:set shiftwidth=4
:set tabstop=4
Sets the relevant values (how big an indent should be / how far a tab should indent).

Code: Select all

:set expandtabs
:filetype plugin indent on
Tells VIM that indents should be spaces, not tabs, and activates the indent plugin.

Code: Select all

:retab
Runs the indent plugin over the current source file.

If you have everything but the :retab in your ~/.vimrc, all you have to do is to call :retab to turn tabs into spaces for the given source file.

(Or vice versa, I know we have some TAB users out there.)

Combined with a macro, re-tabbing several thousand source files is a matter of a dozen keystrokes and 1-2 minutes waiting time. I did just that recently. ;-)

To get rid of trailing spaces:

qq/\s\+$
d$@qq@q

8)

(qq - start recording macro for key 'q'. /\s\+$ - search for 1..n trailing spaces. d$ - delete until EOL. @q - call self. q - end recording. @q - execute macro for key 'q' (until EOF).)
Every good solution is obvious once you've found it.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

You can also use = in visual mode to reindent only a specific part.
Solar wrote:To get rid of trailing spaces:

qq/\s\+$
d$@qq@q

8)
Oh, that's a nice demonstration of macros, maybe I should take a closer look some time.

But I would really use :%s/ \+$//g for this one. ;)
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Solar »

Kevin wrote:Oh, that's a nice demonstration of macros, maybe I should take a closer look some time.

But I would really use :%s/ \+$//g for this one. ;)
Sadly any trivial demonstration of macros (and quite some non-trivial ones) can also be done with a search-and-replace.

One advantage of the macro is that it remains bound to the 'q' key until replaced with a different macro (including being saved on exit). Yes, VIM also keeps a command history, but that's limited in size, and doesn't come with the mnemonic of the key.
Every good solution is obvious once you've found it.
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: Best IDE for OSDev / Cross Compiling

Post by rdos »

The thing is the source sometimes contains 4 spaces for a single indention, and sometimes 8 spaces, so trivial replace will not do it. The tool needs to understand C-syntax, but should not fiddle with { and }.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

= does do this.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Best IDE for OSDev / Cross Compiling

Post by Rusky »

Not quite. If you have both 4 and 8 space indents, retab/= will see that as two different indent levels.
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: Best IDE for OSDev / Cross Compiling

Post by fronty »

With emacs: 1. set up indentation for c-mode (google) 2. C-< C-space C-> M-x indent

I'm not so familiar with or interested in some vi-clone as a more IDE or anything, I use emacs when I need more power, and nvi when doing simpler things.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

Rusky wrote:Not quite. If you have both 4 and 8 space indents, retab/= will see that as two different indent levels.
= doesn't care about the original indentation, it reformats everything (and I seem to remember that it doesn't always understand everything correctly, which is why I'm usually very careful with it).
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Best IDE for OSDev / Cross Compiling

Post by Rusky »

I just ran = on this:

Code: Select all

{
    asdf
        asdf
}
It simply replaced each " " with a tab. My ~/.vimrc looks like this (partial):

Code: Select all

set tabstop=4 shiftwidth=4
filetype plugin indent on
More generally, one interesting setup would be to use eclim to integrate vim with Eclipse. That way you get an IDE with the text-editing capabilities of vim.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

But your test "code" isn't valid C code. vim probably interprets it as one line-wrapped statement. Put a semicolon at the end of each line and it will indent them to the same level.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Best IDE for OSDev / Cross Compiling

Post by Rusky »

Good point. That does work. However, :retab is apparently not equivalent to =, at least when converting to tabs.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

Yes, retab is different, I think it only converts n spaces to a tab (or vice versa).
Developer of tyndur - community OS of Lowlevel (German)
rdos
Member
Member
Posts: 3276
Joined: Wed Oct 01, 2008 1:55 pm

Re: Best IDE for OSDev / Cross Compiling

Post by rdos »

Kevin wrote:= does do this.
I downloaded & installed VIM for Windows, made the changes to the _vimrc file as below:

Code: Select all


:set shiftwidth=4
:set tabstop=4

:filetype plugin indent on

Then I took one of my messed-up source files, but it only works on one or a few lines at a time. It doesn't take the whole source file and reindent it!
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Best IDE for OSDev / Cross Compiling

Post by Kevin »

I was talking about visual mode where you select a block that you want to have reindented (it can be started with v or Shift-v). In normal mode you need to specify the range on which = should work, for example G for "until the end of the file". Do this on the first line and the whole file is reindented, so everything combined gives you a gg=G in normal mode.
Developer of tyndur - community OS of Lowlevel (German)
Post Reply