How do I "select back until the first non-whitespace character" in TextMate 1.5? - textmate

Following a nice advice, I was able to create a macro to "go to the first non-whitespace character" in TextMate 1.5.
Now I'd like to improve it further, in order to "select back from current point up until the first non-whitespace character", i.e. in this line if the cursor was just after the "§" here, it would select: Now I'd like to improve it further, in order to "select back from current point up until the first non-whitespace character", i.e. in this line if the cursor was just after the "§
The trick used in that advice doesn't help here, since once you "search" for the first non-whitespace character, you lose the selection. Any clue?

If you are using TextMate 2 then you can enable indent-aware movement, selection, and deletion.
For more info see https://github.com/textmate/textmate/wiki/Hidden-Settings#keybindings

Related

Are there ways to modify Rstudio's Console behavior when adding missing quotes

I've search both SO and Rstudio's community pages and failed to find aquestion, much less and answer to this annoyance I have experienced with Rstudio. (The Rstudio help pages won't let me post a second question within 12 hours of my first, which was explained as a bug.)
If I type:
(test)
... and then realize that test should be quoted, then putting the cursor at the end to test and entering a double-quote will give me two double-quotes "". It will not do this if I first enter a quote between ( and t and then it will also not give me doubling of the double-quote character at the end of `test. Why should it matter whether I first correct my error at the end of the symbol or at the beginning? Is there anything I can do to modify this quirk> It seems that a syntax aware console editor out to be able to tell when a doubling of quotes does not make sense. It's obviously making that "decision" when the quotes are entered between an open-paren and a character. Why not suppress the unhelpful behavior when it is between a character and a close-paren?

Custom line break in gedit 3.36.2

I'm looking for the option to set the line break at a specific point (e.g. after 75 characters). The option Text Wrapping allows only the line break when the text reaches the end of the screen.
For a cheap solution, you could try the following regex (Hotkey: Ctrl + H)
For tl;dr:
Find (.{75})\s
Replace with \1\n
and then "Replace All"
long version:
Explanation for Find: look for a space character after position 75 of any literal.
Explanation for Replace with: replace this space (i.e. matchgroup 1) with a newline character
For a more sophisticated approach, that means in order to split at a certain operand position and insert a hyphen, there is still room for improvement.
However, I hope this may serve you as a starting point ...
PS: Awh, don't forget to tick "Regular expression" and "Wrap around".

Disable #imageLiteral(resourceName: <..>) preview in Xcode?

I found image literals to be rather distracting than useful.
Is there any way to disable this Xcode feature?
A good method for this is to replace all occurrences of #imageLiteral with UIImage(imageLiteralResourceName:) initializers (thanks for the suggestion, #D6mi!). Here's how you can do it automatically:
Navigate to Find/Find and Replace... (or press ⌥⌘F).
Open the dropdown list on the right side and select Regular Expression.
For the search term, enter the following regex:
#imageLiteral\(resourceName: (.*)\)
For the replacement, enter this:
UIImage(imageLiteralResourceName: $1)
This regular expression captures the value of the resource name with (.*) and inserts it again with $1. The backslashes are for escaping the parentheses, since they count as special characters.
Note that you don't have to use regular expression in this case (as LinusGeffarth pointed out), but it can be more useful in more complex cases than this.

Sublime Text: Find word on same line as each cursor

I have multiple cursors on line with some content that is of variable length and some that's the same content. Due to the variable length content, the lines don't align with each other.
I start with a cursor on each line. I know that only by moving one word at a time to the right, I might not end up at the same spot on each line due to variable content.
How can I do an incremental find for each cursor on the same line and end up with multiple cursors that match my find expression?
Here's a possible solution:
Start with your multiple cursors (done manually, Alt+Enter after a search, etc.)
Select the whole line for each cursor (using Home then Shift+End; etc.)
Open up the search and enable the "In Selection" option (to the right of the "Wrap" option)
Perform your search on those lines, then Alt+Enter to select that match
This would work unless you have multiple matches on the same line. In this case you'll have multiple cursors on the same line

Is there a way to delete all comments in a file using Notepad++?

Notepad++ obviously recognizes all comments as such. Is there a way to simply delete all?
Edit: Stat-R's bookmark method has helped greatly, not only for removing comments but for conditionally removing lines in general.
For a general file, first of all you need to know the comment operator of the language you are writing the file in. For example, in java script the comment operator is //.
For the following code...
In NP++, you need to
Mark the lines that contains '//'. Make sure the bookmark option is enabled.
Then, choose from NP++ menu Search>Bookmark>Remove Bookmarked lines
EDIT:
Another solution after #Chris Mirno 's suggestion is as follows:
Use regular expression. See the image below. It is self explanatory
To understand it better, refer to these
In the Find & Replace Dialog, put the following regex and adjust the search options as depicted.
/\*.*?\*/
Replace with: (empty)
Select Mode: Regular Expression AND .(dot) matches newline
This should remove all your C style comments spanned across lines.
Star-R and Chris Mirno Answer are also Correct and Good.
But For Line Comment:
//.*?(?=\r?$)
Explanation:
// will be the Starting Position
.*? Will be any character
(?=\r?$) will search to the end of the line (as it is required in line comment)
Note:
But Still check each of the line because for example if your code contains soap format like
//www.w3.org/2001/XMLSchema-instance\x2......");
it will capture this line because the starting is // and it goes to end of the line so watch out for this :)
Warning to all using Stat-R's solution:
This method will remove lines of code if formatted like this:
echo "hello"; //This comment will be detected
Following his method, the entire line will be removed.
Therefore make sure to go through and make these comments, their own line before doing this method.
I have had some luck running a macro for the above. Basically:
search for // (F3)
select to end of line (shift+end)
delete (delete)
Put // into the search dialog by just searching for it once. Then record the three steps in a macro, then play it back until EOF.
The first time I did it I had a problem, but then it worked, not sure what I did differently.
Anton Largiader's answer was the most reliable one, including complex inline comments.
However, it will leave many empty lines, including ones with empty characters (space, tabs...) so I would just add another step to make it almost perfect:
After running the macro, just do:
Edit > Line Operations > Remove Empty Lines
OR
Edit > Line Operations > Remove Empty Lines (Containing Blank Characters)
1st option is good if you wish to remove only really empty lines
2nd options will remove every empty line even containing space etc. so there will be no more actual spacing left between code blocks. 1st option might be the safest with some manual cleanup afterwards.
As someone suggested in another post, the simplest and most reliable is maybe to export the all text in .RTF format using Menu Plugin-->NppExport-->Export to RTF and then:
-Open the newly created file in Word
-Select any part of any comment
-On the top-right side of Word clic Select--> Select all texts with similar formatting
-Remove the selected comments all at once (del or cut if doesn't work)
To remove Powershell comments if someone find it handy:
Removing Comment in a Powershell using Notepad ++
To find just lines beginning with # (and not with # elsewhere in the line).
Notepad++ SEARCH Menu > Find
‘Mark‘ Tab – fill in as below.
Select ‘Mark All’ (clear all marks if used previously).
Regex ^[#}
enter image description here
SEARCH Menu > bookmark > Remove (or do anything on the list with
them)
Clear all marks to reset
You can select no comments just code by doing the following:
Regex ^[^#}
enter image description here
Enter ctrl+shift+K to remove comment

Resources