Forum Replies Created
- AuthorPosts
- ShavokParticipant
This is the modified macro I’m working with that covers things quite nicely:
Redraw = false; xPos = document.selection.GetActivePointX(eePosLogical); yPos = document.selection.GetActivePointY(eePosLogical); nLines = document.GetLines(); str = document.GetLine(nLines); if(str.length != 0) { document.selection.EndOfDocument(); document.selection.NewLine(); document.selection.SelectLine(); document.selection.Delete(); } bExtendSelection = false; document.selection.SetActivePoint(eePosLogical, xPos, yPos, bExtendSelection);
I wasn’t clear enough with the example I showed – it should be:
for i in range(1, 10, 1): ~~~~print i ~~~~<----where the line starts
This indentation is perfectly natural if you are going to have additional commands in Python. But on saving the expectation should be:
for i in range(1, 10, 1): ~~~~print i <----where the line starts
Answering your question – yes, I do have line numbers enabled.
ShavokParticipantOkay, okay…fair point :)
The error I picked up with your 0.02 was using the Python syntax (so with Auto Intent in place).
With the following command:
for i in range(1, 10, 1): print i # line ends here
If I pressed enter again it would create a tabbed space. Using your macro – it too create a space in the last line then, so:
for i in range(1, 10, 1): print i ~~~~ # where the line starts
As mentioned – this was not the case with the previous 0.01 code.
ShavokParticipantI like the addition of keeping the cursor where it should be, however I tested your 0.02 version and it does not work with the Auto Indentation activated (unlike the previous one 0.01).
ShavokParticipantI like! Thank you :)
ShavokParticipantGreat! This works very well (and looking at the code, can understand how it works).
The indent “problem” would only occur now and then and the main point of this auto-eof-line is a general good practice.
May I put this forward as a suggestion?
Thanks!
ShavokParticipantThanks for the reply!
So I’ve started on a macro but my coding on this is very weak…
The intention:
- Check if there’s a blank line at the end of the document
- If not, then make a new line
I’ve only got the last part nailed so far…
document.selection.EndOfDocument(); document.selection.NewLine();
Can you please assist on the “if” part?
ShavokParticipantThanks! This worked perfectly.
On closer inspection I see this actually opens up the cmd.exe process. So by introducing this “hack” we actually close the previous cmd.exe then?
Works quite nicely.
ShavokParticipantPerfect! It’s now working as expected. Thanks!
ShavokParticipantAh, I see how you work it. So our selection is the actual space (hence the highlighted area).
While the behaviour is “as expected” – Multiple Select – of the spaces between words. Would it not be more intuitive to incorporate a Multiple Edit instead. The behaviour feels easier to work with as experienced with Sublime or Notepad++.
See how the multi-edit works here: http://notepad-plus-plus.org/features/multi-editing.html
Thanks for the help Stefan though – appreciate the quick assistance.
ShavokParticipantI’ve found the solution – rather than getting too technical of having too many things in the “arguments” line, I used the following:
“/k autopep8 $(FilenameEx) “–in-place””Works like a charm!
ShavokParticipantOkay, I can see how to “properly” use this as it was intended. Actually I was looking for something along the lines of rather than selecting the full work the multiple select is more like a multiple placement of the carat instead. So if I had the following:
The quick brown cat jumps over the lazy dog
I could multiple select the cursor at the end of “cat” and “dog” and then simply type “s” resulting in:
The quick brown cats jumps over the lazy dogs
ShavokParticipantNice! A sneaky way to do it. Thank you :)
- AuthorPosts