Vsvim: Razor Formatting Issues with :w

Created on 9 Apr 2014  ·  5Comments  ·  Source: VsVim/VsVim

I've noticed this mostly in razor template files, (specifically .cshtml files, but once or twice in plain html) but when using :w to save, the formatter tries to format, and the lines will be marked as unsaved. Ctrl+s works properly. Repeated attempts at :w will run the formatter, but still won't properly save.

It's especially bad around Razor if statements, or anything that requires curly braces.

I'm running Visual Studio 2013 Update 2 RC, but this has been a problem since before that installation. Windows 7 x64, if that matters.

Plugins installed:
Productivity Power Tools 2013 (format on save is off)
Web Essentials 2013

This is the code sample that led me to filing the bug:
shot_140409_120037

bug visual studio integration

Most helpful comment

I'm on MacOS and VSVim will not allow me to press <Enter> to complete the command. It allows me to enter command mode by pressing :. Once I type a command and press <Enter>, it presses <Enter> as if I were in insert mode, putting me on a new line while keeping me in command mode. If I press backspace, it will start to delete characters that I typed in the command. So it just seems like <Enter> in command mode on .cshtml files is acting as if in insert mode and does not save the file or finish any command after pressing <Enter>. Another oddity is that if typing :W with a capital 'W', it will allow you to press <Enter> to get out of command mode and not have the issue of going on a new line as if you were in insert mode but the command is not executed. This is the case if including any capital letter in the command.

Also while I'm here, VSVim doesn't work at all in XML files.

All 5 comments

Thanks for filing the issue!

Can you clariify one point. Is the :w operation saving the state of the file before the format or failing to save it at all? I'm curious about the contents on disk vs. the margin indicator as they are somewhat separate and would indicate different problems

Didn't think to check this before.

It seems that when :w is hit, it'll save it to disk, then run the formatter. Opening the file in sublime text shows the text changes, but not the formatting changes it will sometimes attempt.

I came to report this and a cursory search turned up this issue.

This sounds a bit like what I'm observing. When I try to :w to save a Razor file (cshtml) and press Enter to execute the command (from an empty line) it appears to be saving the file and then inserting 4 spaces (i.e., as if a tab had been inserted and converted to spaces). I notice the change typically in Mercurial diff when I find trailing white space on the line. I just now realized that it wasn't me typing the wrong character on this PoS keyboard layout, but rather it seems that Visual Studio and/or VsVim are actually inserting the space when I type :w<Enter>...

I'm on MacOS and VSVim will not allow me to press <Enter> to complete the command. It allows me to enter command mode by pressing :. Once I type a command and press <Enter>, it presses <Enter> as if I were in insert mode, putting me on a new line while keeping me in command mode. If I press backspace, it will start to delete characters that I typed in the command. So it just seems like <Enter> in command mode on .cshtml files is acting as if in insert mode and does not save the file or finish any command after pressing <Enter>. Another oddity is that if typing :W with a capital 'W', it will allow you to press <Enter> to get out of command mode and not have the issue of going on a new line as if you were in insert mode but the command is not executed. This is the case if including any capital letter in the command.

Also while I'm here, VSVim doesn't work at all in XML files.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalebpederson picture kalebpederson  ·  6Comments

jnothstine picture jnothstine  ·  7Comments

academician picture academician  ·  3Comments

thelamb picture thelamb  ·  5Comments

jaredpar picture jaredpar  ·  5Comments