Format current sourcode: operable program or batch file

Post here any ideas/problems/suggestions you have regarding CodeLite's CodeFormatter (AStyle) plugin

Format current sourcode: operable program or batch file

Postby hptphuong » Tue May 30, 2017 2:49 pm

Hi all,

I tried to use "Format current sourcode".

But when I select my code and choose this function, it delete all my code and appear this line"operable program or batch file."

Anyone know what is my issue, May be i miss some setup or wrong in operate.

Please help me fix this issue.(I'm using windown 10 with newest version of codelite 10.0.4)

Thanks & Best Regards,

Phuong Hoang
hptphuong
CodeLite Curious
 
Posts: 8
Joined: Mon May 29, 2017 1:18 pm

Re: Format current sourcode: operable program or batch file

Postby eranif » Tue May 30, 2017 5:58 pm

Please enable CodeLite log and post the log output here.
To enable the log: settings->preferences->misc->log->codelite log level->Debug

The log file can be seen under: %appdata%\CodeLite\codelite.log
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
 
Posts: 5665
Joined: Wed Feb 06, 2008 9:29 pm

Re: Format current sourcode: operable program or batch file

Postby AJenbo » Tue May 30, 2017 6:47 pm

It would also be nice to know if this is for php or c++ and what formatter you have selected under options.

The error you are getting means that windows was not able to locate the formatting tool, so my best guess is that you didn't set the "clang-format path" for c++ or PHP Executable if you are trying to format php.
AJenbo
CodeLite Enthusiast
 
Posts: 41
Joined: Mon May 22, 2017 12:06 pm

Re: Format current sourcode: operable program or batch file

Postby hptphuong » Tue May 30, 2017 9:12 pm

@eranif: There is my log:
Code: Select all
[00:06:50:698 DBG] Formatting file: ' C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp '
[00:06:50:698 DBG] Using C++/Clang formatter
[00:06:50:714 DBG] CodeForamtter: C:\Windows\system32\cmd.exe /C "C:\Program Files\CodeLite\codelite-clang-format.exe" -assume-filename=main_app.cpp  -style="{ BasedOnStyle: WebKit, IndentWidth: 4, UseTab: ForIndentation, Language : Cpp , AlignEscapedNewlinesLeft: true, AlignTrailingComments : true, AllowAllParametersOfDeclarationOnNextLine : false, AllowShortFunctionsOnASingleLine : false, AllowShortBlocksOnASingleLine : false, AllowShortLoopsOnASingleLine : false, AllowShortIfStatementsOnASingleLine : false, AlwaysBreakBeforeMultilineStrings : false, AlwaysBreakTemplateDeclarations : false, BinPackParameters : false, BreakBeforeBinaryOperators : false, BreakBeforeTernaryOperators : false, BreakConstructorInitializersBeforeComma : true, IndentCaseLabels : true, IndentFunctionDeclarationAfterType : true, SpaceBeforeAssignmentOperators : true, SpaceBeforeParens : Never, SpacesInParentheses : false, BreakBeforeBraces : Linux, ColumnLimit : 120, PointerAlignment : Left }"  -cursor=0 -offset=0 -length=508 "C:\Users\hptphuong\Documents\Self C++\learning\first\.code-formatter-tmp.cpp"
[00:06:50:808 DBG] Done
[00:06:50:823 DBG] Formatting file: ' C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp '...is done
[00:06:51:886 DBG] No EditorConfig file found for file: C:\Users\hptphuong\AppData\Roaming\codelite\codelite.log
[00:06:54:911 DBG] No EditorConfig file found for file: C:\Users\hptphuong\Documents\Self C++\learning\first\main_app.cpp

Please help me find what is the issue?
@Ajenbo: I'm working on C++. Please help me to set "clang-format path" for c+
hptphuong
CodeLite Curious
 
Posts: 8
Joined: Mon May 29, 2017 1:18 pm

Re: Format current sourcode: operable program or batch file

Postby eranif » Tue May 30, 2017 9:36 pm

can you try and execute the command from the command line?
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
 
Posts: 5665
Joined: Wed Feb 06, 2008 9:29 pm

Re: Format current sourcode: operable program or batch file

Postby hptphuong » Tue May 30, 2017 10:28 pm

@eranif: Please let me know how to do it? one more, it's ridiculous to reindent by code. It's inconvenient. In sublime, i can make it easy with hot key.
hptphuong
CodeLite Curious
 
Posts: 8
Joined: Mon May 29, 2017 1:18 pm

Re: Format current sourcode: operable program or batch file

Postby eranif » Tue May 30, 2017 10:43 pm

it is also done by hot key in codelite (ctrl-i). it works everywhere, except for you :(

i wanted you to try and run it from the command line just to see if we get some additional information of why it fails to run from within codelite
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
 
Posts: 5665
Joined: Wed Feb 06, 2008 9:29 pm

Re: Format current sourcode: operable program or batch file

Postby hptphuong » Wed May 31, 2017 5:06 am

Please help me run it by command line. I don't know how do it
hptphuong
CodeLite Curious
 
Posts: 8
Joined: Mon May 29, 2017 1:18 pm

Re: Format current sourcode: operable program or batch file

Postby AJenbo » Wed May 31, 2017 3:10 pm

hptphuong:

Open a command prompt (cmd) and paste the following in it:
Code: Select all
C:\Windows\system32\cmd.exe /C "C:\Program Files\CodeLite\codelite-clang-format.exe" -assume-filename=main_app.cpp  -style="{ BasedOnStyle: WebKit, IndentWidth: 4, UseTab: ForIndentation, Language : Cpp , AlignEscapedNewlinesLeft: true, AlignTrailingComments : true, AllowAllParametersOfDeclarationOnNextLine : false, AllowShortFunctionsOnASingleLine : false, AllowShortBlocksOnASingleLine : false, AllowShortLoopsOnASingleLine : false, AllowShortIfStatementsOnASingleLine : false, AlwaysBreakBeforeMultilineStrings : false, AlwaysBreakTemplateDeclarations : false, BinPackParameters : false, BreakBeforeBinaryOperators : false, BreakBeforeTernaryOperators : false, BreakConstructorInitializersBeforeComma : true, IndentCaseLabels : true, IndentFunctionDeclarationAfterType : true, SpaceBeforeAssignmentOperators : true, SpaceBeforeParens : Never, SpacesInParentheses : false, BreakBeforeBraces : Linux, ColumnLimit : 120, PointerAlignment : Left }"  -cursor=0 -offset=0 -length=508 "C:\Users\hptphuong\Documents\Self C++\learning\first\.code-formatter-tmp.cpp"

Hit enter and copy-pate the result to the forum so we can see it.
AJenbo
CodeLite Enthusiast
 
Posts: 41
Joined: Mon May 22, 2017 12:06 pm

Re: Format current sourcode: operable program or batch file

Postby eranif » Wed May 31, 2017 8:35 pm

One thing to note here:
change the filename from: .code-formatter-tmp.cpp to the actual filename you want to format
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
 
Posts: 5665
Joined: Wed Feb 06, 2008 9:29 pm

Next

Return to CodeFormatter

Who is online

Users browsing this forum: No registered users and 2 guests

cron