Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Razor Formatting Issues with :w #1349

Open
myopicmage opened this issue Apr 9, 2014 · 5 comments
Open

Razor Formatting Issues with :w #1349

myopicmage opened this issue Apr 9, 2014 · 5 comments

Comments

@myopicmage
Copy link

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

@jaredpar
Copy link
Collaborator

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

@jaredpar jaredpar modified the milestones: 1.7.0, 1.6.1 Apr 12, 2014
@myopicmage
Copy link
Author

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.

@jaredpar jaredpar modified the milestones: 1.7.1, 1.7.0 Jul 12, 2014
@jaredpar jaredpar modified the milestones: 1.7.1, 1.8.0 Sep 18, 2014
@sgrassie
Copy link

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

@jaredpar jaredpar added the bug label Jan 2, 2015
@jaredpar jaredpar modified the milestones: 1.8.0, 1.8.1 Jan 2, 2015
@bambams
Copy link

bambams commented Mar 11, 2015

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>...

@jaredpar jaredpar modified the milestones: 1.8.1, 2.1.0 Jul 20, 2015
@MatthewCushing
Copy link

MatthewCushing commented Sep 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants