When I jump to line (:76) I end up on a fold, but it doesn't open.
I can quickly unfold the fold and it gets to the right line, but I want to have the fold unfold automatically to save keystrokes.
Is there a way this can be achieved?
The foldopen setting controls which commands will open folds. In :help 'foldopen' we can see the list of possible values:
item commands
all any
block "(", "{", "[[", "[{", etc.
hor horizontal movements: "l", "w", "fx", etc.
insert any command in Insert mode
jump far jumps: "G", "gg", etc.
mark jumping to a mark: "'m", CTRL-O, etc.
percent "%"
quickfix ":cn", ":crew", ":make", etc.
search search for a pattern: "/", "n", "*", "gd", etc.
(not for a search pattern in a ":" command)
Also for [s and ]s.
tag jumping to a tag: ":ta", CTRL-T, etc.
undo undo or redo: "u" and CTRL-R
From reading the documentation you'd expect that set foldopen+=jump would do the trick, but it doesn't work for :76, only 76G. I'm not sure if this is intentional or a bug in Vim.
Using set foldopen=all does work correctly; but may have unwanted side-effects (specifically, you can no longer move "over" a fold with j and k).
:76is not considered a "jump" in vim and is not remembered in the jumplist (:jumps).76Gon the other hand is a jump (documented in:h jump-motions, so unlikely to be a bug).You may want to add that you can use
– Mass Sep 04 '17 at 14:42zvafter:76to open the fold.:76, jumping while launching vim doesn't seem to open folds (example:gvim +76 myfile.tex... I'm using it with the option--servernamewith synctex). Is there a workaround? What's the Ex command for jumping? – PlasmaBinturong Feb 11 '18 at 16:27gvim --servername GVIM "+normal 76G" myfile.texbut it doesn't unfold. – PlasmaBinturong Feb 11 '18 at 16:34gvim --servername VIMTEX --remote '+normal 76GzO<CR>' myfile.tex(for some reason, thezO(open folds) and carriage return are needed. – PlasmaBinturong Mar 26 '18 at 16:39