Your favorite code editor

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Your favorite code editor

Post by nikki »

[mod edit: splitting tangent from original thread]
toglia wrote:Every now and then I here people talking about how cool is vim for coding but for me, someone with a visual studio background (now getting used to eclipse), vim looks like stone age. I have just downloaded it, without any cool plugins it must have, but my first impressions were pretty bad.
Well you might need to do a lot of configuration before it works exactly the way you want it to. For me a lot of stuff has accumulated over time, and it looks like this now (the right-side window is a shell - not vim sorry):-

Image

Code overview, file list, 'tabs' (actually buffers in this case), auto-completion, error message parsing (to jump to error lines). There's even git-integration (so you can read blames and work on merge conflicts with vimdiff, commit from vim and stuff).
I know every thing is done with the keyboard, and it has a lot of keywords for doing cool stuff, but still most programs have a ton of hotkeys too, I don't get it. So, can somebody explain to me why can somebody replace Vim for Eclipse for example... Does, it have everything Eclipse have?
It's highly extensible really easily. I can record a macro, paste that macro into the current text buffer, edit that macro, paste it back into a register (vim 'clipboard slot') and execute it. I can delete a word with 'daw', delete within { } using 'di{', to 'change' instead of 'delete' use 'c' instead of 'd' and so on. And if it still isn't enough, I can pipe text through external programs like 'indent' or 'gofmt' or 'sort' (there's a built-in sort though). There's just too much to say about it - when I edit with it I no longer really have to think too much and keep hitting arrow keys, selecting text or breaking down commands into such simple movements - I can do a lot of things at once and I can think more about the actual code than the text editing (although it might not seem so - more keyboard shortcuts means more to think right? But in my experience after some time it's become so automatic I've at times written ':wq' into text boxes in websites :P ).

I also have a plugin so that in insert mode when I press 'F5' a color-picker window pops up and I can pick a color and it puts it in in the form #aabbcc for example, or a plugin that allows me to draw ascii art right in the text (lines, boxes and stuff). It's really a lot of fun. :)

In 'normal editors', while I'm editing I think, 'hey lets go down to that word and remove this line' and then I proceed to press 'down' a few times and then 'right' a few times while in vim I just type /word (usually first few characters are enough - incremental search tells you). Then I have to press home and then shift+end and then delete (maybe there's a delete-line shortcut I missed, sorry in that case :P) while in vim I just do 'dd'. Or '3dd' for 3 lines. Or ?foo d/bar to delete from previous 'foo' to next 'bar'. Or ':%g/^$/d' to delete empty lines, ':'<,'>g/word/d' to delete only lines containing 'word' within the current selection, or... You get the idea. :)

For a more mouse-based interface like this instead of a keyboard-based one, check out 'acme' from Plan 9.
Or is it just for writing code. In that case isn't bad having to switch between applications to get everything one needs?
By allowing each application to do a single thing you can let it be the best at that. While IDE developers have to concentrate on many things, developers of text editors have to concentrate only on the text editing in their app, and their app turns out to be really good for just that. In IDEs the text editing features are usually not much more than Notepad + some source recognition. And since you can connect programs together with pipes or run Python scripts in vim etc., having to use different programs is hardly a problem. I regularly use cgdb for debugging, vim for text editing, gcc as a compiler, Makefiles or premake for build scripts etc. and love it. Each application is very good at only what it does. 'switching applications' is harder for the kernel context switcher than for me, really. :P

Regular expressions can also be a fantastic tool. To get good with regular expressions you can practice with 'ed' for a while. :)

Since it's 'just' a text editor I can use the same skills for other languages including Python, bash, or for editing emails or in fact - any text at all.

@CABAListic: Isn't ":'<,'>s:.*:callSomeFunc(&);:g" easier anyway?
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: Position of the star in a pointer declaration. Poll

Post by CABAListic »

Depends what you call 'easy'. It's a lot harder to remember for me, that's for sure ;)
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Re: Position of the star in a pointer declaration. Poll

Post by nikki »

It's kinda simple actually. You usually end up writing it in the spot, not remembering it.

We want to replace everything on the line, with itself, but surrounded by 'callSomeFunc( ... )'.

'.' matches any character
'*' matches any number of the previous character
Therefore, .* matches an entire line.
The 'substitute command' is :<range>s:<searchclause>:<replaceclause>:<flags>
We have to search for whole lines, so search clause is ".*".
In the replace clause, '&' means 'the original thing', so you need callSomeFunc(&);.
The range is current selection, which is from top of selection ('<) to bottom ('>) so '<,'>
The flags is 'g' (replace all occurences)

So,

:'<,'>s:.*:callSomeFunc(&);:g

And anyway, if you do a visual select and then type ':' then vim puts in "'<,'>" for you to make things quicker.

So this is like a cool language for some quick text editing stuff. :D After a while it becomes rather intuitive. Just like after a while of learning coding in C++.

And you get to 'reuse' it in sed, awk, perl, grep etc.
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: Position of the star in a pointer declaration. Poll

Post by toglia »

Looks like a steep learning curve, and a lot of practice. But I'm always up for good changes! Do you remember any specific plugins I would need to start writing/debugging c++ code?
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Position of the star in a pointer declaration. Poll

Post by betajaen »

I still think Sublime/E/Textmate are better.

Does VIM have multiple cursors? i.e. Have two or more cursors and type/delete text throughout the document at once? Because Sublime can do that, makes column editing far easier.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: Position of the star in a pointer declaration. Poll

Post by CABAListic »

@nikki: I do know how regex works, in principle. And I do know about vim's automatic selection range :) But my uses for regex are far too few to become fluent in it. Therefore, they are not intuitive to me, and I avoid them. Kind of a vicious cycle, I know ;)

Edit: Looking a second time at your command, I actually recognise it. The only thing I didn't know about was the &, but that particular feature is different in every regex implementation I've seen. They just look really, really confusing, and that's the problem with regex :)
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Re: Position of the star in a pointer declaration. Poll

Post by nikki »

toglia wrote:Looks like a steep learning curve, and a lot of practice. But I'm always up for good changes! Do you remember any specific plugins I would need to start writing/debugging c++ code?
Get a good colorscheme (I use 'wombat'), and get codepad.vim (direct paste+run to codepad.org), color_picker.vim, CSApprox.vim (gui color scheme in terminals too, not just gvim), c.vim (this is extremely awesome for C code - 'idioms' like for ( ; ; ) { } can be easily inserted with keybinds, it automatically puts comment headers and stuff), minibufexpl.vim (for seeing a list of 'buffers' on top of the screen), NERD_tree.vim (rather silly name but awesome sidebar file explorer), supertab.vim (automatic context-sensitive tab-completion launcher), table.vim (for doing text tables), taglist.vim (view overview of source code), DrawIt (draw boxes etc.), omnicppcomplete (for C++ code completion). Just look around on vim's wiki and try stuff until you get what you like.

@betajaen: Like, how does that work? You can choose the 'current' cursor and then only that cursor is used, while others 'stay put'? That could maybe be emulated with 'marks' and a little scripting in vim. For tables, there are some vim plugins that will do auto-formatting of tables and stuff. Anyway, I'll read more about the feature in sublime you're talking about...
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: Position of the star in a pointer declaration. Poll

Post by toglia »

The fact that sublime is windows only makes it quite disappointing. Not that I'm a PC hater, but lately I'm only working on embedded Linux systems.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Re: Position of the star in a pointer declaration. Poll

Post by nikki »

toglia wrote:The fact that sublime is windows only makes it quite disappointing. Not that I'm a PC hater, but lately I'm only working on embedded Linux systems.
You can find vim on a lot of OSes. ;)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Position of the star in a pointer declaration. Poll

Post by betajaen »

toglia wrote:The fact that sublime is windows only makes it quite disappointing. Not that I'm a PC hater, but lately I'm only working on embedded Linux systems.
Check out e then it's for Windows and Linux. Textmate is best editor there is, it's bundle system is amazing, both e and sublime can use them.
nikki wrote:@betajaen: Like, how does that work? You can choose the 'current' cursor and then only that cursor is used, while others 'stay put'? That could maybe be emulated with 'marks' and a little scripting in vim. For tables, there are some vim plugins that will do auto-formatting of tables and stuff. Anyway, I'll read more about the feature in sublime you're talking about...
There is no choosing, you can have two or more cursors. Where they are, and you type your actions appear at them all at once. For example, I was working on the gorilla dejavu file the other day, I wanted to append a piece of text to a number of lines. So I just right shift clicked on the areas on the lines (dragged down), then I had ~100 cursors. Typed what I wanted in and done.

I'm not going to get into editor wars with everyone, but Nikki, those sort of features your talking about in VIM have been in other things for years.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: Position of the star in a pointer declaration. Poll

Post by CABAListic »

betajaen wrote: I'm not going to get into editor wars with everyone, but Nikki, those sort of features your talking about in VIM have been in other things for years.
But given that vim has been around for years, it probably had them first ;)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Position of the star in a pointer declaration. Poll

Post by betajaen »

VIM was made in the 1990s on the Amiga and we had very good text editors back then. ;)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: Position of the star in a pointer declaration. Poll

Post by CABAListic »

Perhaps; still, after adoption, vim's command modes feel more natural to me than what was shown in the e showcast. I'm kind of a keyboard guy, I don't like using the mouse while typing. And vim commands are superiour to any shortcut I've ever used, simply because you don't need to press awkward combinations of Ctrl, Alt and letters. But ultimately it really comes down to preference; vim is certainly not the saviour :)
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Re: Position of the star in a pointer declaration. Poll

Post by nikki »

betajaen wrote:VIM was made in the 1990s on the Amiga and we had very good text editors back then. ;)
The original 'vi' came out in 1976. :P

But I agree - use whatever you want to use, as long as you're comfortable with it, and like it. vim is a good editor, but unfortunately it has a very steep curve. 'vimtutor' can help with that though. I will try 'sublime' the next time I'm on Windows.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Position of the star in a pointer declaration. Poll

Post by betajaen »

JustBoo wrote:A small point for people who have to use Visual Studio; you can get column-based selection blocks, instead of the normal row-based selection, by holding down the ALT key whilst simultaneously holding down the mouse left-button and "swiping" the mouse around.
I forgot that existed. Problem with that though, it erases when you type, and the text appears where the cursors once was. But it's handy in some situations. Unless I'm doing it wrong.
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: Position of the star in a pointer declaration. Poll

Post by toglia »

JustBoo wrote:you can get column-based selection blocks, instead of the normal row-based selection, by holding down the ALT key whilst simultaneously holding down the mouse left-button and "swiping" the mouse around.
I'm curious, can't try this right now, and eclipse doesn't seem to do anything special with it. What do you mean by "swiping"?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Your favorite code editor

Post by Kojack »

A small point for people who have to use Visual Studio; you can get column-based selection blocks, instead of the normal row-based selection, by holding down the ALT key whilst simultaneously holding down the mouse left-button and "swiping" the mouse around.
From the pointer thread that this thread was split off from:
Kojack wrote:
One particular strong point that I really miss from many, many text editors is block selection. In vim you can select a block of text (i. e. 10 colums of 5 lines, instead of selecting the whole of the 5 lines)
Both VS and Notepad++ let you do that using alt+drag mouse or alt+shift+move cursor.
They don't have the insert before/after each line feature you mentioned though. If I was doing what your example did, I'd put in the callSomeFunc(); first, duplicate the line as many times as needed (shift+alt+l to cut a line, then ctrl-v a few times to paste in copies), then block select the tokens, then paste within the brackets of the first callSomeFunc(). VS will past each line of the block into the brackets of the corresponding function.
:)

VIM was made in the 1990s on the Amiga and we had very good text editors back then.
Uedit was the best. Vim didn't even have arexx. :)
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Your favorite code editor

Post by betajaen »

Kojack wrote:
VIM was made in the 1990s on the Amiga and we had very good text editors back then.
Uedit was the best. Vim didn't even have arexx. :)
GoldED and Cygnus ED are the ones I can remember. I was very excited when a copy of GoldED was given free with a copy of Amiga Format. :D
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Your favorite code editor

Post by Kojack »

GoldED and Cygnus ED are the ones I can remember. I was very excited when a copy of GoldED was given free with a copy of Amiga Format.
I learnt C using Cygnus Ed back around 1990 or so. :)

I uses a few other editors, but then moved to Uedit when it's creator Rick Stiles died and it changed from shareware to freeware (his last request or something, can't remember the details).

Having arexx made it pretty damn powerful. For those who don't know, arexx was a scripting language for amiga apps. But unlike most modern scripting languages which run within the app itself, arexx ran in a global process. Apps could expose an arexx port and register functions. An arexx script could connect to a port by name and call it's functions. This meant that a single script could (for example) connect to uedit, grab the currently selected text into a variable, connect to another program and pass that text to it. So any program with arexx support could control or share info with any other program with arexx.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Your favorite code editor

Post by betajaen »

Kojack wrote:I learnt C using Cygnus Ed back around 1990 or so. :)

I uses a few other editors, but then moved to Uedit when it's creator Rick Stiles died and it changed from shareware to freeware (his last request or something, can't remember the details).
I finally remembered the first text editor I used on the Amiga; Edword. I got that Free on a copy of an Amiga magazine too.
Kojack wrote:Having arexx made it pretty damn powerful. For those who don't know, arexx was a scripting language for amiga apps. But unlike most modern scripting languages which run within the app itself, arexx ran in a global process. Apps could expose an arexx port and register functions. An arexx script could connect to a port by name and call it's functions. This meant that a single script could (for example) connect to uedit, grab the currently selected text into a variable, connect to another program and pass that text to it. So any program with arexx support could control or share info with any other program with arexx.
Tell them about Datatypes Kojack! :D
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 116

Re: Your favorite code editor

Post by mkultra333 »

I used Amos and Blitz Basic on Amiga. That's where I started programming again after the long lapse when I stopped programming Basic on the Vic20 and C64.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: Your favorite code editor

Post by madmarx »

For C++ completion, did you try GCCsense http://cx4a.org/software/gccsense/ ?
Visual Studio is enough for me most of the time.
For the other languages, often notepad++.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13

Re: Your favorite code editor

Post by nikki »

Well, yesterday I decided to clean up m vim config a bit and rebuilt it all from scratch keeping stuff in separate folders. I also put it on git and made commits as I built it. If you're interested you can find it here. If you want to try it make sure to symlink '~/.vimrc' to '~/.vim/vimrc'.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58

Re: Your favorite code editor

Post by betajaen »

I found RockScroll a few minutes ago, it allows you to have a mini-map of code in Visual Studio. I can't seem to configure it, and as it's an addin it will only work with non-express versions of Visual Studio. But I'm sure some people will like it.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4308
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 137

Re: Your favorite code editor

Post by spacegaier »

I had that installed once, but didn't like it that much. Did not really enhance my workflow and optically it isn't that appealing either ;) .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...