I am working on Python files and jump to beginning section to fix some imports and come back to point I am working on.
I want to use Bookmark
, when I make a change on beginning of the file and come-back to the latest line I am working on. I was using ctrl+u+space
, but I need to press multiple times to get back to latest point.
For following condition if possible:
- When I jump to beginning of the buffer, also automatically I want to add a bookmark to the latest line I am working on.
- Afterwards I made some changes on the
import
section, I want to get back to the latest bookmark (which is the right before I jumped), with a keybinding without entering its name intoJump to bookmark:
.
Setup:
(global-set-key "\C-x\ ," 'beginning-of-buffer);
(defadvice bookmark-jump (after bookmark-jump activate)
(let ((latest (bookmark-get-bookmark bookmark)))
(setq bookmark-alist (delq latest bookmark-alist))
(add-to-list 'bookmark-alist latest)))
Example:
1 | import hello
2 | import world
...
20 | import python
...
1000| line_I_am_working_on = 100
I am on line 1000. Than I pressed Ctrl+x+,
to jump to beginning of the buffer. Than I go to line-20 by pressing line-down (Ctrl+p
) and make a change. As final step I want to jump back to line 1000.
beginning-of-buffer
which is bound toM-<
pushes a mark with the current position - you can then get back to it withC-x C-x
.C-x C-x
gets back to the position but it also highlights it from beginning of the file to the position. Is it possible to disable highlighting whenC-x C-x
is pressed?transient-mark-mode
, although IMO it's far too useful to disable. I use C-g.C-x C-x
intoC-x C-x
and followed by (C-g
orC-SPC C-SPC
)C-u C-x C-x
instead.