[PATCH] D27501: clang-format-vsix: add command to format document

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 13:23:14 PST 2016


hans added inline comments.


================
Comment at: tools/clang-format-vs/ClangFormat/ClangFormat.vsct:76
+        <Strings>
+          <ButtonText>Clang Format Document</ButtonText>
+        </Strings>
----------------
amaiorano wrote:
> hans wrote:
> > I think File would be better than Document when referring to source code.
> > 
> > But it seems a little annoying to need two menu alternatives. Could we make the regular "Clang Format" option just format the whole file if there is currently no selection, or would that be confusing?
> The reason I chose "Document" is that it mimics the existing functionality in Visual Studio:
> {F2661117}
> 
> As you can see, "Ctrl+K, Ctrl+F" is bound to format selection by default; which I assumed is the reason "Ctrl+R, Ctrl+F" was used for Clang Format (Selection). So along the same lines, I bound "Ctrl + R, Ctrl + D" to Clang Format Document.
> 
> I don't really have a problem with having multiple menu options, although we could have both of them underneath a "Clang Format" top menu, with "Format Selection" and "Format Document" as sub menu items.
> 
> As for annoyance in menus, I think most developers would reach for keyboard shortcuts in this case anyway. Furthermore, the next feature I want to add, building on top of this one, is allowing the user to enable "Format on Save", which would make this even easier to use.
I see, I didn't realize they call it documents. And if they also have separate commands for formating selection and formating the whole file, maybe that makes sense for us too.

Right, I also imagine folks would use this from the keyboard, but there too it's annoying to have two shortcuts for the same thing. But again, if that's how it's generally done in VS...

I'd like to hear from Manuel on this patch too, though.


https://reviews.llvm.org/D27501





More information about the cfe-commits mailing list