Category: Notepad++

Sep 03 2013

How to use Notepad++ to fix up clear out some numeric strings

I am writing a script that is a copy of another older script. As such I need to replace some floating point strings with an empty string (to speed up future updates to the script.) Specifically I need to replace this... '90.12') with this... '') Notepad++ to the rescue. I opened up the Find/Replace dialog (CTRL-H) in n++ and set the Search Mode to Regular expression. In the “Find what:” box I put this… '(\d{2}).(\d{2})'\) In the “Replace with:” box I put this… ''\) It worked perfectly!! Seth
Oct 30 2012

How to use Notepad++ to fix invalid date formats.

I was just sent some xml files that had dates in this format... 31/09/2012 (dd/mm/yyyy) This date format won't work in some of our systems so I needed to change some of the dates to the format 09/31/2012 (mm/dd/yyyy). Notepad++ to the rescue. I opened up the Find/Replace dialog (CTRL-H) in n++ and set the Search Mode to Regular expression. In the "Find what:" box I put this... (\d{2})/(\d{2})/(\d{4}) In the "Replace with:" box I put this... $2/$1/$3 It worked perfectly!! Seth
Nov 16 2010

Can someone tell me how to run a batch file from Notepad++

I thought I could run a batch file from Notepad++ directly using nppexec by (or the built in run command) by typing CMD $(FULL_CURRENT_PATH)

But since notepad++ HAS a CMD command (which open the cmd shell in the npp console) then it is not working. So running the above command opens cmd shell in the npp console but does not run the batch file. At that point I can run $(FULL_CURRENT_PATH) AND it will run the batch file. But then I have to type exit to get our of command shell mode.

Can someone tell me how to run the batch file I am current editing in npp directly in npp.

Nov 16 2010

Can someone tell me how to run a batch file from NOTEPAD++

Hello,

I thought I could run a batch file from Notepad++ directly using nppexec by (or the built in run command) by typing CMD $(FULL_CURRENT_PATH)

But since notepad++ HAS a CMD command (which open the cmd shell in the npp console) then it is not working. So running the above command opens cmd shell in the npp console but does not run the batch file. At that point I can run $(CURRENT_FULL_PATH) AND it will run the batch file. But then I have to type exit to get our of command shell mode.

Can someone tell me how to run the batch file I am current editing in npp directly in npp.

Thanks in advance.

Seth

Nov 16 2010

Can someone tell me how to run a batch file from NOTEPAD++

I thought I could run a batch file from Notepad++ directly using nppexec by (or the built in run command) by typing CMD $(FULL_CURRENT_PATH)

But since notepad++ HAS a CMD command (which open the cmd shell in the npp console) then it is not working. So running the above command opens cmd shell in the npp console but does not run the batch file. At that point I can run $(CURRENT_FULL_PATH) AND it will run the batch file. But then I have to type exit to get our of command shell mode.

Can someone tell me how to run the batch file I am current editing in npp directly in npp.

Thanks in advance.

Seth

Nov 16 2010

Can someone tell me how to run a batch file from Notepad++

I thought I could run a batch file from Notepad++ directly using nppexec by (or the built in run command) by typing CMD $(FULL_CURRENT_PATH)

But since notepad++ HAS a CMD command (which open the cmd shell in the npp console) then it is not working. So running the above command opens cmd shell in the npp console but does not run the batch file. At that point I can run $(FULL_CURRENT_PATH) AND it will run the batch file. But then I have to type exit to get our of command shell mode.

Can someone tell me how to run the batch file I am current editing in npp directly in npp.

Nov 12 2010

Text File Weirdness

Yesterday I was working on someone’s computer and I wanted to run a couple of SQL scripts.  But the task, which should have taken mere minutes, took close to 45 minutes.

Here’s why.

I downloaded a sql script from my website but any tool that I would use to run the script was failing.  Even though I know the script was good.

When opening the script in Notepad it looked like this…

munged

…when is should have looked like this.

fixed

 

To figure out what was wrong, Notepad++ too the rescue.  Here is what each the file looks like in Notepad++…

Broken.notepad

Fortunately for me, Notepad++ is “smart enough” to not care what the Windows standard is.  The trick is that Notepad++ is showing me that each line is being delimited with an ASCII Line Feed (LF) character.  Windows expects lines in text files to be delimited with 2 ASCII characters, the Carriage Return and Line Feed (CRLF).  In other words, it should like like this…

notepad  .fixed

 

How to fix it.

To fix it I used Notepad++ Advanced find and replace fixture.  Do CTRL-H (a windows standard keystroke, BTW, for opening the Find/Replace dialog in most programs.)

Here is what the dialog should look like in order to fix the file…

notepad   find dialog

Notice at the bottom of the dialog I selected the Extended feature, which allows me to find and replace non-visible ASCII characters.  Use \n to find Line Feed characters (think of “n” as meaning New Line) and use \r to find Carriage Returns (think of “r” as meaning Return.).

After doing the replace, not only would the file open correctly in Notepad but my SQL tools would run the script.  

The next thing to figure out is how the file got munged.  I suspect that the wonderful, new, free FTP client that I am using may have done it when I uploaded the file and that I need to tweak some setting next time I use it.   Maybe my next post I can disclose the fix.

Hope this helps someone else.  Enjoy.

Seth

PS  In case you don’t realize it yet from this post…NOTEPAD++ ROCKS.

UPDATE – I discovered that it was not the FTP upload that was munging the file.  It was the mere act of downloading it from the website.   So now I am zipping scripts before putting them there.

Aug 26 2010

GetDateTime batch file outputs a timestamp string

Yesterday I posted a couple of Notepad++ scripts.  One of them referenced a GetDateTime.bat file.  For that Notepad++ script to work that batch file has to be in the Notepad++ root folder.

Here is the batch file…

@echo off
for /f "tokens=1-3 delims=/.- " %%a in ("%DATE%") do set CUR_DATE=%%c%%b%%a
for /f "tokens=1-4 delims=:., " %%a in ("%TIME%") do set CUR_TIME=%%a%%b%%c%%d
echo %CUR_DATE%_%CUR_TIME%

Seth

Aug 25 2010

Notepad++ scripts to remember

#SHOW CONSOLE – RUN THIS AT NOTEPAD++ STARTUP
NPP_CONSOLE ON
CLS

#SQL EXECUTE SELECTED – SAVES SELECTED TEXT TO TEMP FILE AND RUN IN SQL
NPE_CONSOLE v+
$(NPP_DIRECTORY)\GETDATETIME.BAT
SET TEMP_FILE= $(SYS.TEMP)\$(OUTPUTL)
NPE_CONSOLE v+
SEL_SAVETO $(TEMP_FILE) :a
CLS
SQLCMD -S.\SQLExpress -E -i"$(TEMP_FILE)"

#SQL EXECUTE FILE – EXECUTES THE WHOLE SCRIPT IN SQL
#YOU COULD USE INPUTBOX TO GET THE DATABASE NAME
cls
SQLCMD.EXE -E -S.\SqlExpress -i "$(FULL_CURRENT_PATH)" -deScore

#OPEN EXPLORER – OPEN THE EXPLORER WINDOW FOR THE CURRENT FILE
NPP_RUN EXPLORER "$(CURRENT_DIRECTORY)"

Aug 06 2010

To run SQL Scripts from Notepad++

To setup notepad++ to execute sql scripts that you are writing do the following: 1.  Be sure that you have the nppexec plugin installed. 2. Hit F6 to open the nppexec execute window. 3.  In the Commands window type the following command...
SQLCMD.EXE -E -S.\SqlExpress -i "$(FULL_CURRENT_PATH)" -deScore
4.  Click Save and give the nppexec script a name.  Make a mental note of the scripts name. 5.  Click on Settings/Shortcut Mapper and choose the Plugin commands tab. 6.  Scroll through the list and find your new script (given in step 4). 7.  Double click the script and assign a keystroke to the script.  (I use ctrl-alt-F5) Test it out. Enjoy.