Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

because you can just write a mapping or function that does that.


How can it be helpful in the real world? If I want some repetitive behaviour (create new class, generate code) I'll use the IDE behaviour customised to my needs and in the most exotic cases I will add a generating template. But I can't ever imagine myself deleting the selection up to the fourth f from the current cursor position. For me this is not a feature, it's a huge bug because you can delete massive amount of text just because your cursor was in the wrong place. The most important behaviour of a code editor is to be context aware and transform your code accordingly to the language rules, not just blindingly execute a series of commands that edit text generated from "random" key strokes.


> If I want some repetitive behaviour (create new class, generate code) I'll use the [...] behaviour customised to my needs

AKA a function.

> code editor is to be context aware and transform your code accordingly to the language rules, not just blindingly execute a series of commands

If you "blindingly" execute a series of commands in anything, it's not going to end well. Also, vim can load commands/plugins based on filetype, or any arbitrary condition you want.


A class is certainly not a function, I was speaking about generating valid code in response to a sequence of key strokes / mouse events. If I am building a new module I start with a concrete class and just right click -> extract interface -> select appropriates / all public members and I have a new file with the interface definition. If I am modifying the class I pull the members up to change it. If I just created a new class from scratch I make it inherit the interface, ALT+ENTER and all methods are generated. with the uncountable templates you can do pretty much whatever you want, from generating constructors, creating properties and who knows what else. I have seen people use it live in conferences to generate part of their demo code. All of this is safe and the result compiles correctly apart from the uncommon cases where you need to explicitly ask to make it non compilable.


If it goes wrong, just hit u to undo.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: