Author Topic: General question about VLIDE and Coding  (Read 5777 times)

0 Members and 1 Guest are viewing this topic.

StykFacE

  • Guest
General question about VLIDE and Coding
« on: December 14, 2011, 09:57:00 AM »
Hello to all. I just have a general question that I've actually always been curious about. I was wondering how y'all handle "code formatting" when you are deep into programming? I know when I'm monkeying around with simple code, or modifying another person's program to fit my needs, I notice that when I Tab over it doesn't look as spaced out or clean as some (or most) of the main programmers I see on this board and the CADTutor.net site.

Is this a manual process to literally Spacebar over "x" amount of character space to get it how y'all like it? Or is there a super secret method that guys like me don't know about?

Here is a screenshot of a program that I have. I made it about 4 years ago but half of it was helped by someone over at CADTutor.net IIRC. I'm starting to get around better with the VLIDE, for instance I know how to use the "Load Active Edit Window" and "Load Selection", which is nice when I'm monkeying around with things.



Just trying to learn from the pro's is all. Thanks in advance.  :kewl:

ronjonp

  • Needs a day job
  • Posts: 7529
Re: General question about VLIDE and Coding
« Reply #1 on: December 14, 2011, 10:04:14 AM »
CTRL-ALT-F  :-)


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: General question about VLIDE and Coding
« Reply #2 on: December 14, 2011, 10:05:20 AM »
I don't use the vlide, I use Textpad or UltraEdit 99% of them time, and in both the tab key is smart (tab and shift tab) -- formatting so ez I really don't have to put much effort or thought into it. It would actually be harder for me to write unformatted code because it hurts my eyes so much.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #3 on: December 14, 2011, 10:10:47 AM »
CTRL-ALT-F  :-)
Or click on one of the two triangle icons.
First will format everything, second will only format selected content.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #4 on: December 14, 2011, 10:18:39 AM »
Yep, the "triangle" buttons like attached. Just remember to setup your Tools --> Environment Options --> Visual LISP Format Options to something you like. I prefer not having those default ;_ end of ... comments added all over the place.

About the tab not being a smart-tab, that's sometimes a blessing in disguise. But I hear what MP's saying! In some instances I hate the way VS formats the code as soon as you close the brackets, but usually that can be fixed through some settings.

Where VLIDE (for me) falls far short of others is with folding and code completion / intellisense.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #5 on: December 14, 2011, 10:21:00 AM »
irneb, what are you using to make your screenshots?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: General question about VLIDE and Coding
« Reply #6 on: December 14, 2011, 10:23:47 AM »
I've gotten annoyed at tab-formatting so often, I set tabs to insert spaces rather than tab characters.  Seems to work out better that way.  That way, when its opened on other computers it doesn't matter what their tab "width" is set to.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #7 on: December 14, 2011, 10:29:52 AM »
Oh, and BTW your comments will be formatted stragely. There's a trick in VLIDE where it depends on the 1st few characters of a comment how it will get formatted. E.g.

I'm using XNView to do screen captures. Just because I'm used to it.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #8 on: December 14, 2011, 10:32:09 AM »
I've gotten annoyed at tab-formatting so often, I set tabs to insert spaces rather than tab characters.  Seems to work out better that way.  That way, when its opened on other computers it doesn't matter what their tab "width" is set to.
+1
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #9 on: December 14, 2011, 10:32:24 AM »
I'm using XNView to do screen captures. Just because I'm used to it.
Cool. I don't mind using print screen and pasting into paint/photoshop, but an actual screen capture to file would be nice. Thanks.

Sorry for the thread jack. Resume regular programming.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

nivuahc

  • Guest
Re: General question about VLIDE and Coding
« Reply #10 on: December 14, 2011, 10:42:14 AM »
I'm using XNView to do screen captures. Just because I'm used to it.
Cool. I don't mind using print screen and pasting into paint/photoshop, but an actual screen capture to file would be nice. Thanks.

Sorry for the thread jack. Resume regular programming.

 :angel: cough

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #11 on: December 14, 2011, 10:46:40 AM »
Cool. I don't mind using print screen and pasting into paint/photoshop, but an actual screen capture to file would be nice. Thanks.
Great! I've simply un-learned that habit since one of the keyboards I use goes into that "special M$ keys" at the top and then the Print Screen button doesn't do what it's supposed to.

The XNView thingy isn't actually only used for screen captures though. It's much more comprehensive than that. E.g. I tend to export to PNG from PS and then use XN to batch print. The prints come out 10x faster that way, strange how PS's printing hogs the printer for minutes before anything starts to happen - especially if there's transparencies involved. But not so when exporting to JPG/PNG.

Back on topic: I would definitely love to see a VLIDE update. Perhaps it would be possible to simply use Scintilla for this, it would allow even Intellisense - though not type based due to Lisp being a flexible typed language. But I can't see why it would be impossible to have with showing only function calls directly following an open parenthesis, while only showing variables and other symbols directly following a space. It would make mistypes a lot less prevalent.

And for huge LSP files, folding is an absolute MUST! And then just for fun  :lmao: I'd also adore being able to use regular expressions in Search & Replace, not just the usual wild-card matching.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #12 on: December 14, 2011, 10:51:29 AM »
I'm using XNView to do screen captures. Just because I'm used to it.
Cool. I don't mind using print screen and pasting into paint/photoshop, but an actual screen capture to file would be nice. Thanks.

Sorry for the thread jack. Resume regular programming.

 :angel: cough
Very nice. Thanks. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #14 on: December 14, 2011, 10:59:55 AM »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #15 on: December 14, 2011, 11:04:34 AM »
Enough about the screen grabbing  :pissed:

To get the best of both worlds you can do what I sometimes do: Have the LSP open in VLIDE as well as your favourite editor (mine's SciTE). That way you can have code completion, proper formatting, folding, regex S&R ect. As soon as you save from the external editor, you can return to VLIDE, it will tell you the file's changed and ask if you want it reloaded. Then you can go ahead and do your debugging there.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

nivuahc

  • Guest

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: General question about VLIDE and Coding
« Reply #17 on: December 14, 2011, 11:27:45 AM »
I'm with the others in this thread who use a text editor. I don't have worry much about formatting but I have adopted a sort of system in my editor which is actauly best described as "adaptive" (I got that word from the link below) based upon filetypes. Ive been thinking that I may want to expand on this this theory a bit and try to create a system which will allow for alternates for each filetype but that's later.

REF:
I answered a similar question about this on stackoverflow a while back.
http://stackoverflow.com/a/6950427/875064
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

StykFacE

  • Guest
Re: General question about VLIDE and Coding
« Reply #18 on: December 14, 2011, 10:05:29 PM »
Awesome! Thanks for the replies everyone. I'll keep that in mind when I'm monkeying around with more code. I never thought about looking at the two icons with the triangles, I'll mess around with those tools as well.

I've seen that some people has extremely clean formatted code and it always seemed like it would be a pain to try and make it that way, but a well organized code says something about the coder in my opinion. Glad to finally hear it from you guys.

 :kewl:

StykFacE

  • Guest
Re: General question about VLIDE and Coding
« Reply #19 on: December 14, 2011, 10:08:37 PM »
Yep, the "triangle" buttons like attached. Just remember to setup your Tools --> Environment Options --> Visual LISP Format Options to something you like. I prefer not having those default ;_ end of ... comments added all over the place.
Irneb, would you mind elaborating on your settings a bit from your screenshot? I see that they do not match the default settings. I understand some of the options but others I don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #20 on: December 15, 2011, 01:39:02 AM »
Some of these are a bit of personal preference. You can of course choose your "own look":
  • Right text margin: I've set mine to 120 since my screen handles a longer line than the default. And it helps to allow longer EOL comments. There's a max limit and I think this is it.
  • Narrow style indentation: 2 so an indent is rather minimal and nested indents don't start forcing new lines when they become too deep.
  • Max wide car length: 9 ... I haven't changed this, can't even remember what it does.
  • Single semicolon comment indentation: 1 so EOL comments are placed directly after the line, not trying to align to a specified character position, which IMO makes the comment detatched from the code and harder to relate to its own line (even though it might look more neat).
  • Closing paren style = @ new line with outer indent: means my ending parenthesis would be at the same indentation as the corresponding open paren, and it's placed on a new line of its own. Just my preference. Some like using the @ same line approach, thus formatting more like Python / rather Scheme.
  • Insert tabs = OFF: Pressing tab actually creates spaces instead of a \T character. Works better if your code is viewed on other PC's as well and also works better when copying to forums. Otherwise the tab char-length might differ and cause irregular indents.
  • Save formatting = Yes: means these settings are saved in an auto-generated comment at the end of the LSP file. Ensures proper formatting on any PC, so you don't need to re-setup VLIDE on another PC / version of Acad.
  • Insert form closing comment=Off: I don't like having auto-generated comments like ;_ end of defun, ;_ end of while ;_ end of if, etc.etc. IMO it makes the code "ugly"
  • Approximate line length = 100: A trial & error setting to make comment lines at end of line (EOL comments) not start at new lines too easily. There's a max limit and I think this is it.
  • Preserve existing line breaks=On: If I make a new line, I'd rather it stays that way than VLIDE remove the NL character. Usually I'd have pressed Enter for a reason.
  • Setting case to symbols = both OFF: I want my CamelCase as I've typed it. All lower / All UPPER is a bit unreadable IMO.
  • Long list format style: If I type a list into the code I don't want each item on its own line. That's just a waste of space. I could've gone with Multi-column and it might then space each item to a "smart" tab position, but I don't care about that for such lists.
« Last Edit: December 15, 2011, 01:43:19 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #21 on: December 15, 2011, 01:55:18 AM »
I've seen that some people has extremely clean formatted code and it always seemed like it would be a pain to try and make it that way, but a well organized code says something about the coder in my opinion. Glad to finally hear it from you guys.

 :kewl:
:lmao: I think it just says they use the formatting function. I don't think you get many who'd be so pedantic as to press 1000's of spaces in different lines just to get the formatting "just-right". The only guys who "have-to" do that is Python programmers, where the indentation actually has some meaning in the action of the source code. But then their editors would have an auto-indent feature anyway.

Edit: Actually, the manual "spacing" to indent always gives me an itchy feeling as I generally see typists hit the spacebar 10 times per line to go and indent a paragraph in Word. I've given up trying to explain to them the "oh-so-new" feature of Word where you can simply set a paragraph's intents to have it done automatically for you.
« Last Edit: December 15, 2011, 02:05:54 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: General question about VLIDE and Coding
« Reply #22 on: December 15, 2011, 07:00:46 AM »
I never use the formatting utility in the VLIDE, I format the code manually as I write it  :-)

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: General question about VLIDE and Coding
« Reply #23 on: December 15, 2011, 07:30:46 AM »
Good thread.  Very good thread.  2 birds with one thread.  :wink:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: General question about VLIDE and Coding
« Reply #24 on: December 15, 2011, 08:10:59 AM »
I never use the formatting utility in the VLIDE, I format the code manually as I write it  :)
You mean you format it in NotePad?

If in any other decent code editor (even VLIDE) most of the formatting is done on the fly. VLIDE's format function just completes where its auto-indenting falls short.

So what you mean is you type the code into VLIDE and then fix the screwups with its auto-indent manually? ... Well ... I did say "most" wouldn't be as pedantic  ;)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: General question about VLIDE and Coding
« Reply #25 on: December 15, 2011, 08:19:22 AM »
I never use the formatting utility in the VLIDE, I format the code manually as I write it  :)
You mean you format it in NotePad?

No, I write the code in VLIDE, but don't use the option to format it automatically.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: General question about VLIDE and Coding
« Reply #26 on: December 15, 2011, 08:24:52 AM »
lmao @ `pedantic'.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: General question about VLIDE and Coding
« Reply #27 on: December 15, 2011, 09:30:25 AM »
I never use the formatting utility in the VLIDE, I format the code manually as I write it  :)
You mean you format it in NotePad?

No, I write the code in VLIDE, but don't use the option to format it automatically.
That's a lot of work.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: General question about VLIDE and Coding
« Reply #28 on: December 15, 2011, 09:52:06 AM »
:lmao: I think it just says they use the formatting function.

And yet you'd be wrong.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: General question about VLIDE and Coding
« Reply #29 on: December 15, 2011, 09:52:49 AM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst