Background
When using the Jetbrains IDE, I like to use the bookmark feature, especially when I’m new to a project, I’ll use it to mark some key code, but the problem with this feature is that it can’t be backed up, even I lost a bookmark of a project that I’ve been following for more than a week, it’s very heartbreaking, so I’m looking for a way to save the bookmark.
vscode
In fact, when using vscode, I found a good plugin: inline bookmark, which allows you to write markup directly in the comments of the code, so it’s easier, the code is the document. But this way is not perfect, for example, these comments submitted to the code base is not very suitable (or I can not spend so much time to write these comments well), so I often need to cut a review branch out, used to save these comments, so this will be code disconnected, not very convenient.
Then again, this plug-in can only be used in vscode. vscode has many features that I like, but it’s not perfect when writing Go (maybe I’m not using the right posture), for example
- outline does not show the properties and methods of the struct in a very good way
- outline can’t show all the methods of a struct (it should only show the methods in the same file)
- go to implement can’t be used across files (still can only access the implementation in the same file)
So I ended up using Goland as my main IDE.
Saving bookmarks
When I started using the bookmarks feature I searched if there was an export configuration in the IDE settings, but unfortunately I didn’t find it.
Then after a lost bookmark, I searched for how to save it, and saw the following tirade.
It seems that Jetbrains products used to have the ability to export bookmarks, but the reason for removing it doesn’t seem so make sense: > Bookmarks management is a good feature.
Bookmarks management is a good feature but there are two important notes about that:
- There is no much sense in providing export without import.
- It looks like bookmarks should be not a standalone feature but a part of common ‘task management’ functionality;
Okay, so you still have to do it yourself. Also in the above tirade someone mentioned that bookmarks are saved in the workspace directory, so I abstracted directly to the following two commands so I could quickly back them up.
[root@liqiang.io]# PROJECT_ID=$(cat .idea/workspace.xml | grep ProjectId | awk '{print $3}' | awk 'BEGIN {FS="="} {print $2}' | tr -d '"')
[root@liqiang.io]# cp ~/.config/JetBrains/GoLand2022.1/workspace/$PROJECT_ID.xml bookmark-backup.xml