打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Adding Code Formatting Tools in Notepad | T...

Adding Code Formatting Tools in Notepad++

I am a big fan of beautiful code, not only in terms of quality of programming but also formatting the code nicely so that it is easy on eyes.

If you are using a full-blown IDE, they come with their own formatting facility, but if you are using a multipurpose editor such as Notepad++, then you may have to use a plugin to format your code. There are many 3rd party programs that can be used with Notepad++ that will help you format your source code without going through a lot of effort.

I use different tools for different languages. I use PerlTidy for formatting my Perl code, and AStyle for certain other languages. Here are the steps taken to add AStyle to Notepad++. Please check the AStyle website for further information on AStyle and its options.

First you need to make sure you have NppExec plugin added to your Notepad++ by going to Plugin menu.

NppExec Menu

Download AStyle. The zip archive includes all the source and an  executable. You can simple copy the executable to a suitable location (For this demo, I am copying it to H:\tools\AStyle.exe. Or you can recompile from the source.

Go to NppExec under Plugin menu and click on Execute or hit F6. You will get the Execute dialogue box.

Execute Dialogue Box

Select ” from the dropdown box if it is not already selected.

Type in the following commands in the window:

h:\tools\AStyle --style=allman "$(FULL_CURRENT_PATH)"
npp_open $(FULL_CURRENT_PATH)

The first line, formats the code and saves the file. The view doesn’t get refreshed, so we need to reload the file from disk, and npp_open does that in the above. Note that I am using AStyle with –style=allman flag which uses broken brackets.

Hit the save button and it will ask you for a name, just type an appropriate name and hit OK to run.

Execute AStyle

You could stop right there and every time you need to run the command, just go to Plugins -> NppExec -> Execute… But let’s go one step further.

Under Plugins, go to NppExec and click on Advanced Options.

NppExec Advanced Options

Select “Run AStyle” from the Associated Script drop down menu and then hit the “Add/Modify” button. Make sure the “Place to the Macros Submenu” is ticked.

This will add a new option in Macro Menu.

 

Notepad++ Macro Menu

That is it. Hope you have found this short tutorial useful.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Notepad++如何调试VBS脚本
Notepad++插件推荐和下载
全网最全的NotePad 配置(适用于Python程序设计)
NotePad++
Notepad 运行JAVA代码
在NotePad++中使用NppExec配置Python编辑运行调试环境
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服