4

I know how to ignore most files in VS Code as follows:

 "files.exclude": {
        "**/*.pdf": true,
        "**/*.out": true,
        "**/*.exe": true,
        "**/Music": true 
    },

But I also want to ignore files with no extension or suffix, for example the filename is smartPoint (which is generated after I run file smartPoint.cpp in VScode). Is there any way I can ignore this kind of Unix file on a Mac?

Picture describe

2 Answers 2

0

There's an alternate way that I got some headway with, but it doesn't work as well as I'd like. For what it's worth, here it is:

Essentially, set "explorer.excludeGitIgnore": true, in settings.json and then use gitignore binary files that have no extension.

(in .gitignore):

*
!*/
!*.*

This would only work in the first place though if you are okay with gitignoring these.

Unfortunately, for reasons I don't understand, VS Code's interpretation of the ignore file fails to unignore all directories, which... renders this approach pretty much unworkable. But I thought I'd share it anyway. Maybe that behaviour of VS Code is a bug and maybe it'll get fixed someday.

Sign up to request clarification or add additional context in comments.

Comments

-1

Since you have generated files with the same basename I was hoping that some form of hiding derived files would work. Example for typescript/javascript:

 "files.exclude": {
   **/*.js: { "when": "$(basename).ts" }
 }

But what to put in the key **/.js? I tried

   "**/*": { "when": "$(basename).cpp }      // doesn't work
   "**/$(basename)": { "when": "$(basename).ts" }  // doesn't work
   "**/[^.]*": { "when": "$(basename).ts" }  // doesn't work
   "**/*[^.]*": { "when": "$(basename).ts" }  // doesn't work
   "**/*[^.]{1,10}": { "when": "$(basename).ts" }  // doesn't work

I really thought some version of the last would work - excluding files with no extension - but no.

WARNING: dirty hack follows. As a lark I tried

"**/[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.]": {"when": "$(basename).cpp"},

since smartPoint has 10 characters. That works !! But not for new - 3 characters. But you can have both:

"**/[^.][^.][^.]": {"when": "$(basename).cpp"},   // works on 3 character file names
"**/[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.]": {"when": "$(basename).cpp"},  // works on 10 

so yes, unless someone comes up with a better solution, you could include all the versions you need for the number of characters (for 1...10, etc.) you might have.

Ugly, but simple.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.