Sublime Forum

Why is this such a mind-reading game?

#1

I’m new here. I had a simple goal: get a blank page, paste in some unformatted c code, format it (indents etc) and then coment out a couple of lines. After stumbling around in the “dark” for about an hour, I sort of figured it out but the formatter I found didn’t get it right; it left an entire {} block unindented.

I then found this after a search: " Package Control is the first thing that you have to install right away"

Not that having package control is much goot because the entries in the repo don’t really document the use of the plugins - but - and here’s my first big question:
If this statement is true, why isn’t package control part of the default install? Why should it take a newcomer multiple web searches just to discover this, much less how ro use it.

I have no doubt that many are guru-class users who can’t even remember a time when they weren’t fluent in sublime, but maybe they shouldn’t be the ones to write the skimpy, cryptic documentation. Since they charge for this why do’t they pay someone to write some decent docs and some recipes for configuring for commong scenarios like c, python, etc. So newbkes could get a running start.

Based on today’s experience I’m just not sure that it’s worth the time it would take to get this all grokked. It’s ok to dismiss this as a rsnt, unless it’s viewed as a suggestion that the product needs some work.

0 Likes

#2

You can automatically reindent using the Edit > Line > Reindent menu or “Indentation: Reindent Lines” in the command palette. Commenting out lines is similar: Edit > Comment > Toggle Comment (and the associated key binding).

If you’re trying to use a fully featured formatter my advice is usually to get it working outside of Sublime Text and then integrate it if desired. For clang-format for instance searching for “Sublime Text clang format” yields https://packagecontrol.io/packages/Clang%20Format with install instructions.

0 Likes

#3

Thanks.
Option 1, using reindent doesn’t get the indents right. There is a {} that has {} blocks withing it that don’t get indented.
Option 2 - I installed clang-format and it is in my path. I stopped Sublime and restarted. On the command palette, “Formatter: Beautify with ClangFormat” does absolutely nothing although, since I installed LLVM I no longer get that method about “out of scope”.

According to “Set the path to the clang-format binaries. You can do this from within Sublime Text by choosing Clang Format - Set Path from the command palette. Hint: the path should look something like this [path/to/clang]/clang/bin/clang-format. If clang-format is in your system path, you shouldn’t need to do anything.” it should have worked. There is, of course no “Clang Format - Set Path” option in the command palette, so I couldn’t have done that anyway. So much for “instructions” :slight_smile:

0 Likes

#4

It’s working fine on my end, but that plugin doesn’t provide a “Formatter: Beautify with ClangFormat” command palette entry. It has “Clang Format: Format Selection” entry and adds a keybinding. Instructions for usage are also in the link I posted.

It looks like you’ve also installed the Formatter package which of course has its own instructions.

0 Likes

#5

I’ll have a look at all that but, as I tried to convey, I have no clue what I’m doing, which packages might be appropriate or, really, how to use them.

I feel like I been dropped by parachute into quicksand. There are obviously people to whom this must all be intuitively obvious, but I’m not one of them.

By the way, clang-format works as ecpected from the command prompt. I’m not clear how/where to put its path ino the config since it doesn’t seem to be able to find it in the path.

0 Likes

#6

Are you launching Sublime Text from the command line? What operating system are you on?

0 Likes

#7

Windows, double-click icon on desktop

0 Likes

#8

I use Windows 10 with Sublime Text 4 and clang-format. It works very well. Are you able to try launching Sublime from Command Prompt (or whatever terminal client you are using?). If clang-format works in that instance, then it is likely a path issue.

0 Likes

#9

No change when starting from command line

0 Likes