When I edit C/C++
files time to time in the middle of buffer,
I decide to add #include
at the begin of buffer.
Save position jump to begin of buffer, then insert suitable line, then
jump back is boring.
I wonder may be there is standard (emacs build-in/elpa/melpa) solution to deal with such problem?
I mean some elisp code to find #include
directives at the begin of file and insert new one.
If there are no, may be there is such solution for other languages for import
(Java, Python), use
(Rust) and so on which I can modify for C++
?
C-r #include RET
to find an existing directive, do your thing there, then useC-u C-SPC
to jump back to where you were. The magic works becauseC-r
pushes the starting point to the mark ring. – YoungFrog Aug 17 '17 at 8:01