Where are bookmarks stored? How do I keep them if I copy the script file elsewhere? How do I add them to version control?

Answered

One of the features I miss the most from Spyder is recognising lines starting with "#--- Part A of my code" as a bookmark, and showing "Part A of my code" in a kind of project explorer, for easy navigation.

 

Will PyCharm ever introduce something similar?

 

Right now, I can add bookmarks:

  • F11 to toggle a bookmark
  • Shit + F11 to open the vookmark windows
  • CTRL + Enter to add a description

 

Slightly more convoluted, but it works. However:

  • Where exactly are the bookmarks stored? The .idea folder has some xml files but I couldn't find the bookmarks there
  • If I want to copy the file to another folder (e.g. to start a new project based on an existing one), how can I keep the bookmarks? Which files would I need to copy together with the Python script file?
  • How do I ensure that, wherever the files with the bookmarks are stored, they are added to version control? I am using git locally. Is the answer different if I use PyCharm's version control and if I use an external tool like GitKraken? Eg maybe Pycharm knows where these other files are and commits them automatically, whereas GitKraken won't know?
11 comments
Comment actions Permalink

Hi,

Bookmark export seems to have been deprecated quite a while ago: https://youtrack.jetbrains.com/issue/IDEA-111619

Bookmarks are stored in .idea/workspace.xml , so you could copy that between projects or using VCS.

0
Comment actions Permalink

Are you sure that bookmarks are stored in workspace.xml?

 

If I open it,I see text matching the comments of my git commits, but nothing related to bookmarks. I have 6 bookmarks, to which I have added a description, but I can't find any of these 6 descriptions.

 

Also, since workspace.xml contains data on git commits, wouldn't I mess things up by copying that to another file?

 

Come on, JetBrain, just copy the bookmark functionality from Spyder, it makes so much more sense!

2
Comment actions Permalink

My apologies, I based my answer off another answer from https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000394030-exporting-Bookmarks-possible-

But now that I went and checked it, it seems to be no longer true. The bookmarks are currently stored in <pycharm_config>/workspace/<workspace_id>.xml , under the following:

<component name="BookmarkManager">
...
</component>

You could copy-paste that from one workspace file to another, but I understand it might be cumbersome to deal with those IDs.

P.S. PyCharm config directory can be located according to https://intellij-support.jetbrains.com/hc/en-us/articles/206544519

0
Comment actions Permalink

Thank you for your reply.

 

So somewhere in the Pycharm config directory there are files with information on all my projects!!! This is crazy, it is incredibly poor design, and it poses a number of issues:

 

  • backup: exactly what files do I need to backup?

  • restore: say there is a hard drive failure. I restore my project folder with all my code. But how do I restore a PyCharm configuration with all the bookmarks etc?

  • version control: similar to the above, what files need to be added to version control? Does restoring a previous version restore the correct bookmarks or is there a risk everything will get messed up?

  • moving files: what if I need to move my project to a new folder? How do I ensure that the data in the config directory now points to the right location?

  • confidentiality: it doesn't really affect me, but imagine some kind of freelance consultants working on projects subject to non-disclosure agreements. Are they aware that PyCharm stores bookmarks for ALL projects in its config directory? Even if the consultant hands back the code to the client, bookmarks could let you reconstruct some of the key steps. Imagine telling a law firm that Microsoft Word will store the bookmarks for all the contracts they work on, for all their clients, in the Word config directory - they'd go ballistic, and rightly so!

 

It's also very hard to make sense of these xml files. Yesterday I worked only on one project; based on 'date modified', I found 2 xml files, and opening them I found the one with the bookmarks, but the file names are something like "1swQrt159" etc etc.

4
Comment actions Permalink

Have there been any changes on this?

To be honest this is the main reason why I have switched back from PyCharm to Spyder. I would really like to have a way to flag bookmarks in the script itself - come on, it's not complicated!

1
Comment actions Permalink

I may have found a solution.

PyCharm lets you add other text patterns that can be recognised in the ToDo pane, e.g. "optimise" etc. This is explained here: https://www.jetbrains.com/help/pycharm/using-todo.html

 

By setting “sect” as one such pattern, comments beginning with #--- SECT or with ### SECT will be recognised by PyCharm in the ToDo pane, and by Syder in the outline pane.

 

This means nothing is stored in separate xml files, and the same code can be easily shared with anyone using Spyder (with no additional changes) or PyCharm (as long as they make this tiny change to their settings).

0
Comment actions Permalink

@Eugene Morozov  Fortunately yes !

And I must admit that I'm very disappointed in the fact that there is no IntelliJ team support for this topic,
or some guidance to help people, as this happens pretty much after all new versions of IntelliJ and it's update,
and as a consequence, it impacts a developer's work, at least for us who work on really big projects.

So I've decided, to make this short tutorial how to restore back your bookmarks for Windows 10 users :

As of version 2020.1, IntelliJ operates under hidden Windows user AppData folder :
e.g. C:\Users\<windows.user.name>\AppData\Roaming\JetBrains\IntelliJIdea<version>\workspace

Even more, under C:\Users\<windows.user.name>\AppData\Roaming\JetBrains there are previous versions, (along with backup folders !)
and under appropriate version, in folder "workspace" there are all modifications, in the form of <funny_ssh_like_fileName>.xml
(e.g. 1lFTpsTT6pUo3tksBtYpwaD5qZ2.xml)

So, in my case, I've :
1. opened ~\AppData\Roaming\JetBrains\IntelliJIdea2020.3\workspace
2. sort files to descend based on modified flag
3. opened the newest one, and found that there is just one new bookmark, without previous ones !
4. so, I opened next recent xml, found <component name="BookmarkManager"> and copied everything in between,
into the current IntelliJ workspace file

1
Comment actions Permalink

Dobri7 your comment really helped me, your post led me to the true location of the workspace file where my bookmarks+favourites were being stored, thank you.

My problem was I was stuck trying to delete an item from my favourites list through the IDE, but it didn't do anything - the item remained. Deleting it from the file solved the issue

1
Comment actions Permalink

Unfortunately it is still the problem.

On Linux I was able to export them all with: grep -r '<bookmark url=' $HOME/.config/JetBrains/CLion2020.3/workspace/* . But there is no straightforward way to associate it with project, the name of xml file in app config location is the id of the project stored in project's folder in .idea/workspace.xml: <component name="ProjectId" id="1q4YOC4a4NM32p6nIRGQNQJMLR5" />.

0
Comment actions Permalink

Jakub Faber

Please vote for https://youtrack.jetbrains.com/issue/IDEA-98138

I added your feedback to the issue thread so that the dev team can see it.

0
Comment actions Permalink

The bookmarks are currently stored in <pycharm_config>/workspace/<workspace_id>.xml , under the following:

<component name="BookmarkManager">
...
</component>

You could copy-paste that from one workspace file to another, but I understand it might be cumbersome to deal with those IDs.

 

Unfortunately, I did copy all the `BookmarkState` entries under here:

<project version="4">
  <component name="BookmarksManager">
    <option name="groups">
      <GroupState>
      <option name="bookmarks">

but looks like PyCharm's first action on restarting was to wholesale delete all my new entires… giving up for now. 

0

Please sign in to leave a comment.