Search code examples
vimvim-plugin

Vim GitGutter deletes unstaged hunks


I'm having some weird problems with my GitGutter. If I have added some lines to my code:

1 oldline1
2+newline1
3+newline2
4 oldline2

and then I close the file (wq) and reopen it. it looks like this:

1 oldline1
2+---- 2 lines: newline 1-----------------------
4 oldline2

Why is it doing this and how can I prevent/resolve this problem in the future?

Thanks in advance for any tips! Edvin


Solution

  • What you are seeing is called a "fold", it is a compressed view that shows multiple similar line into a single line. Nothing is deleted, it is only hidden.

    You can read :help fold-commands from inside vim.

    The most useful and basic commands are :

    • zo : to open a fold (while being on the active line)
    • zc : to close the fold again

    Similarly if you want to apply it on the whole file you can use zO and zC.

    I am not familiar with GitGutter but if you don't want to use any fold, search for that keyword in the configuration file (if there is any).