Manually add current position to Recent Locations
I am trying to solve the problem of deleting the bracket with its paired bracket, see this question: https://stackoverflow.com/q/40992566/7869636
As a quick note, the questions asks: if I have `[[a for a in l1 if a!=0]]`, how can I get `[a for a in l1 if a!=0]` with a single shortcut?
My approach is to use macros for that.
The idea is the following:
- Place the cursor after the closing bracket.
- Remember current position
- Jump to paired (opening) bracket
- Delete opening bracket.
- Jump to previous location
- Delete closing bracket.
Now, I have a problem with returning to the previous position. Unfortunately, the previous position is not remembered. I can see it in Recent Locations (Ctrl + Shift + E).
I thought of following approaches to remember position before first jump.
- Use a temporary bookmark. But bookmarks do not remember line number.
- Use a go to Line:Column (Ctrl + G). I tried to copy (Ctrl + C) the value, then for the second jump use that (Ctrl + V). But macros recording seems to ignore copying to clipboard.
- Manually make edit (add space) after closing bracket so that I could jump to last edited place. Unfortunately, still that location is not placed to Recent Locations.
- Use jump to literally previous cursor position (makes sense if using jumps). Unfortunately, I did not found such action.
- Find a way to manually add specific position (current) to the Recent Locations.
The last approach is what I want to ask from Support. I was able to achieve “manual adding specific position” when (Ctrl + Click) on the position of interest (I must be on a different position before that, Ctrl + Click on the current position does not do the trick). It tries to go to the symbol definition (which fails for bracket), and also adds the position to Recent Locations.
Is it possible to achieve that thing without click? So I would be able to record a macros. Or can you please add the action “Add the current position to Recent Locations”?
I created this topic in PyCharm, but it is general for other IDEs.
Please sign in to leave a comment.
Hi,
Not sure about that. Recent locations are populated automatically as you go through the code, but the logic doesn't cover each and every jump. For example, I tried “Go to Line” feature and, indeed, it doesn't remember the position in this case.
So, I would suggest submitting a usability issue to https://youtrack.jetbrains.com and list all cases when the recent location is not saved.
I have filed a feature request here: https://youtrack.jetbrains.com/issue/IDEA-335622/Recent-Locations-does-not-remember-specific-jumps