question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better vim support?

See original GitHub issue

I started using prettier recently and ran into troubles with the vim format-on-save support. The recommended approaches don’t restore cursor position cleanly (even with the <C-o>s), causing the code to jump upon save. Saving code is a reasonably frequent operation for me, and this behavior is fairly disturbing. See the gif below:

current vim format-on-save

Other vim plugins that perform format-on-save, like vim-go and elm-vim don’t have any such jumps. They use winsaveview() and winrestview() to save/restore the window position. I repurposed the vim-go implementation for prettier in my .vimrc file at https://github.com/karthikv/dotfiles/blob/5a289e0/vimrc#L152-L203. It works like so:

alternate vim format-on-save

If there’s interest, I’d be happy to factor this out into a simple vim plugin to help other prettier users. The installation would be a single command with standard vim package managers (vim-plug/vundle/neobundle/pathogen). If not, that’s fine too, but I’d love to hear any thoughts.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
tmcwcommented, Feb 10, 2017

You might want to try out Neoformat - it supports prettier by default and is able to keep cursor position while auto-formatting on save.

1reaction
lydellcommented, Feb 22, 2017

@landabaso Try Neoformat as suggested by @tmcw – it works great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 12 Best Vim Plugins to Improve Your Workflow - MakeUseOf
The 12 Best Vim Plugins to Improve Your Workflow · 1. NERDTree · 2. Emmet-vim · 3. vim-gitgutter · 4. commentary.vim · 5....
Read more >
Vim Awesome
Vim Awesome is a directory of Vim plugins sourced from GitHub, Vim.org, and user submissions. Plugin usage data is extracted from dotfiles repos...
Read more >
7 Vim Editors for Better Productivity in 2022 - Geekflare
In this article, we'll show you some excellent vim-inspired editors that help you be more productive. Let's get rolling!
Read more >
Top five Vim plugins for sysadmins - Red Hat
Top five Vim plugins for sysadmins · Vim Airline is a plugin that replaces the standard Vim status line with a fancy and...
Read more >
Great VIM Plugins in 2022 - hacking C++
Much better and more lightweight than the old 'a.vim' plugin. braceless. commands, text objects and visual aides for coding in whitespace-aware ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found