$FilePath$ with forward slashes

Answered

I need the $FilePath$ variable to return the path to the current file with forward slashes instead of backslashes ( I am on Windows). Is there any way to achieve that?

0
4 comments

Hi Dbambusek,

Could you please describe your case in more detail? Where do you need it returned and to what purpose?

0

The $/FilePathRelativeToProjectRoot$ did partly the job for me. However I am looking for a universal macro, that would give me the path to the currently opened file in editor with forward slashes on both Windows and Unix.

$/FilePathRelativeToProjectRoot$ exists only for Windows

$FilePath$ gives path with backward slashes on Windows and with forward slashes on Unix

So I need a macro that returns e.g. 'myproject/src/assets/css/current_file.css' inependently on the running OS

0

There is no such predefined macro in IntelliJ IDEA, I'm afraid, but you can always create your own custom one and embed it into the IDE via a plugin.

See this documentation article and this post for details on how to achieve that.

0

Use variable this way - $UnixSeparators($FilePathRelativeToProjectRoot$)$

0

Please sign in to leave a comment.