I'm writing a function that should run a linter and then populate the location list with appropriate linting messages.
The problem is that when I call the function (by running :Phpcs
), the cursor jumps to the top of the file, which is undesired, since I plan on running the linter every time I save the file and then check the location list before committing any changes to the repository.
I have cut everything unneeded away and the following is what is left in my .vimrc
I have tested the function in both Vim 8.2.43000 and Nvim 0.6.1 - Both installed from Homebrew on Mac OS Big Sur.
function! RunPhpcs()
echo "Hello world"
endfunction
command! Phpcs execute RunPhpcs()
The desired functionality is that when I run the function it does not jump to the beginning of the file.
I have read through a somewhat similar, but different, question and tried both getpos()
/setpos()
and winsaveview()
/winrestview()
but with no luck.
What am I missing to make the function call not jump to the beginning of the file when executed?