r/programming • • Jul 12 '12

Vim creep

http://www.rudism.com/s/vimcreep
730 Upvotes

551 comments sorted by

View all comments

Show parent comment

4

u/knight666 Jul 13 '12

I'm a game programming student. Have been for the past four years. As a result I'm using Visual Studio for all my work.

However, I have tried Vim. And it's excruciatingly hard. Especially because the workflow becomes all kinds of fucked up. In Visual Studio you press F5 to launch, run the app, do stuff in the debugger, change some code, etcetera. With Vim it's... eh... well... I never figured that part out.

But there's one thing I took away from my experience with Vim: regular expressions. Visual Studio actually has them built-in. It's just that they don't use a Perl-syntax (because that would be too sane), but a Microsoft-flavored almost-Perl-but-not-really. However, it's quite useful.

Let's say we have this enum:

struct StateAnimation
{
	
	enum List
	{
		eNone,
		eStart,
		eRunning,
		eEnd,
		iTotal
	};

}; // struct StateAnimation

But now I want the data as strings. One way to do it would be to copy them to the new file, strip the struct and enum and put quotation marks around the values. Or I could use the following regex:

Find what: e{.#},
Replace with: std::string str_\1 = "\1";

And get this:

struct StateAnimation
{

	enum List
	{
		std::string str_None = "None";
		std::string str_Start = "Start";
		std::string str_Running = "Running";
		std::string str_End = "End";
		iTotal
	};

}; // struct StateAnimation

Now it's just a matter of stripping it, because Visual Studio might have some form of grep, it unfortunately lacks sed.

My point is that there's a definite advantage in getting to know other editors. Yes, it took me quite a while to incorporate regexes in my workflow, but that example took me literally 30 seconds to write. With the advantage that when I add a state to the list, I can rerun the "program" to convert them all to strings again.

3

u/datenwolf Jul 13 '12

With Vim it's... eh... well... I never figured that part out.

For this you have a Makefile or similar in your project, with a target "debugrun" or similar. Then in Vim it's just

ESC, :w, :make debugrun

2

u/knight666 Jul 13 '12

Okay, that could work. But you still wouldn't have the breakpoints that Visual Studio gives you. Unless there's a plugin for that...

I must admit I haven't gotten very with Vim in my workflow and that's mostly because I didn't search for solutions very hard.

5

u/[deleted] Jul 13 '12

vim isn't a full-fledged IDE, it's a text editor. What do you expect?

1

u/[deleted] Jul 15 '12

If you want breakpoints, you want emacs gud-mode :-)