Tag Archives: Notepad++

Edit Files Live on the Server

I've been a web developer for many  years now and I must say I feel a little foolish for not thinking of this earlier. I've been wasting countless amounts of time waiting for files to upload and doing the mundane tasks involved in updating files and uploading them to a server when I didn't really have to. Here's why.

Today I got fed up with editing my file in Notepad++, switching to Filezilla,  finding the file in a folder on my desktop, uploading the file by dragging it to Filezilla and finally testing my online website or app. I decided to Google the term "Edit files live on server" and found https://cyberduck.io/ that has an amazing product which allows you to type in your FTP details, just like I used to in Filezilla, and open a connection to my server. Then it gives me a directory tree on my server. CyberDuck allows me to click on any file on my server and open it in Notepad++ on my desktop, edit it and save it right back to the server without having to click and drag it to another program like I used to do for so many years.

This is the best program for a developer I have found in years. Traditionally I do not favor fancy programs to help you write code or frameworks to make things "easier" because I found that they only complicate matters in the long run, CyberDuck is the exception however. It is great so far, but I've only been using it for an hour now, so if I find any flaws, I will report them here asap. I just wanted to share this. If you are interested in downloading the CyberDuck app for yourself, simply CLICK HERE or the link above and look for the two download links on the left side of the page. Do not use the first download link you see at the top of the page because it is a sponsored ad and will try to trick you into downloading something else. I hate those types of ads, but none-the-less, I still recommend CyberDuck!

Like I said, it's great when used with Notepad++, so if you'd like the experience I had, download Notepad++ too. Just google it, it's easy to find.

How to delete lines in Notepad++ that contain specified text string

Have you ever had a list similar to this one:

Some text here...spam...some text here
Some text here...good...some text here
Some text here...good...some text here
Some text here...spam...some text here

...and you wanted to delete all the ones that contained a certain string of characters? If so, I have the solution!

  1. Open the file with the text you want to filter in Notepad++. If you don't have it, google it and download it.
  2. In the top tool bar of Notepad++, click on search/replace to open up the search and replace dialog window.
  3. In the replace dialog window, where it says "find what" enter: .*spam.*
  4. That's dot star then the text or character string you want to search for followed by another dot star. Replace the word "spam" in my example with the text you want to search for.
  5. Check the box towards the bottom left of the replace dialog window that says "Regular Expression" to enable the use of regular expression search mode.
  6. Leave the "Replace with" field blank so it deletes the lines it finds that text in and doesn't replace it with something.
  7. Click "Replace All" to the right of the dialog window and it will replace all lines that contain spam with a blank line.

Here's what your find and replace dialog will look like:

Snap 2014-12-15 at 12.14.49

Delete all blank lines in Notepad++

Now that you have gotten rid of the lines you didn't want, you may also want to delete all those pesky blank lines with another search & replace trick. Here is how:

Simply go back up to the Notepad++ toolbar and navigate to "Edit/Line Operations/Remove Empty Lines" and it will quickly remove any empty lines without having to do a complicated regex which you can also do if you know how.

 

Handy Regex Notes for Notepad++

Here are some regex expressions I have found to be useful with notepad++ as a programmer:

  1. .*' - (dot star apostrophe), finds all  occurrences of "'s".
  2. .*word - finds all occurrences of any number of characters up to the word "word".
  3. word.* - finds all occurrences of the word "word" followed by any number of characters.
  4. [a-z][a-z][a-z].com  - finds all three letter .com domain names(lower case). Simply change the a-z to uppercase to look for uppercase 3 letter domains.
  5. [a-z][a-z].com - finds all two letter .com domain names in lower case. Change to A-Z for uppercase.
  6. [0-9][0-9][0-9].com - finds all three number .com domain names.
  7. Adult T - [0-9a-zA-Z ]+, - finds all occurrences of "Adult T -" followed by another word or number(or combo) and then a comma.
  8. .*[\|]  - Finds and replace all but the domain name in cases where ea. line in a file looks like: celebrification.com | scottludbrook@aanet.com.au(make sure that the regex ends in a space). Note that the pipe character is escaped with a backslash.
  9. ^\s - find are replace all blank lines. Deletes blank lines when search for this and replace with nothing.

Make all lowercase

While not a regex, I learned how to change all characters to lowercase using Notepad++ today as well. All you do is select the entire document or the part you want lowercase and right click then select "lowercase" and DONE!

Find & Replace Part of a String

Lets say you have a CSV file with these contents:
1 Adult T - Led Zeppelin, black, XL

2 Adult T - Motley Crue, black, Med

3 Adult T - Grateful Dead, tie die, Sm

...and you need to replace:

"Adult T - Grateful Dead," with "Grateful Dead T-Shirt,"

This is where the \1, \2, \3 abilties of Notepad++ version 6+ comes in very handy. First you define parts one and two in parenthesis, so as in the #7 example above you'd change it to this instead:
Search for:
(Adult T - )([0-9a-zA-Z ]+),
and replace with:
\2 T-Shirt,

The above tells Notepad to find the text "Adult T - " and any string after it until you hit a comma. Then in the last line above, it says to replace it with what is in the 2nd parenthesis and to add T-Shirt to it so "Adult T - Led Zeppelin," becomes "Led Zeppelin T-Shirt,". Works like a charm!

By reading and studying the above examples, you should be able to modify the regex expressions to do just about anything. I am using only simple regular expressions here to make it easier to understand because most of us have a terrible time understanding all the regular expression rules.

How to Add Spell Checker to Notepad++

I have been using Notepad++ as my coding text editor of choice for several years now. One of the main things I use it for is to create web pages in PHP and/or HTML. Over those years, I can't count the number of times I have been chastised for my somewhat poor spelling and numerous typos the end up in the final product or website that I turn over to my clients. Well, it's time I did something about it, don't you think? Well, my clients think it is and several have mentioned it, so here I am years after starting to use Notepad++, finally installing a spell checking plugin. Here we go!

Also, I recently added a bug fix to this tutorial that describes how to fix it so that you can use the learn button and otherwise save changes to the dictionary files. When I installed Aspell, none of this worked and it was aggravating, so I learned how to fix it and will share at the bottom of this article, so if you are here to learn how to fix the bugs in Aspell, skip down to the bottom of this post. If you get an error something like the following one, then the bottom section is for you:

Ensure that the security settings of the "C:/Program Files (x86)/Aspell" folder for the current user allow for modifying and writing

Aspell

Usage example with replace by text same as misspelled text

Steps to installing Spell Check for Notepad++

Before you start, you should close any open applications, or at least close Notepad++ so it can get the updates needed if any while you install the plugin.

  1. Go to http://aspell.net/win32/ and download the "Full Installer" to your desktop or downloads folder and double click on it when it's downloaded fully to set it up on your machine. I selected the defaults mostly, but did check the boxes to allow a desktop icon and a right click menu option so I could take advantage of the drag and drop document feature and quick spell check options.
  2. During the installation process, after clicking through the terms of service and a couple other routine clicks, you will come to the "information" dialog. It will say: "Please download and install at least one dictionary from http://aspell.net/win32/dicts" So, naturally, I clicked on the link and came to find that it was a dead link and that the spell check plugin hasn't been kept up for the past ten plus years. So, determined, I went to back to the same webpage above, , where I downloaded Aspell from, and found the dictionary list I was seeking. Lucky me! Then I scrolled down and found the one for English entitled "aspell-en-0.50-2-3.exe" (Click to download) and clicked on it to download the English dictionary I needed. You can click on the link I just provided to download it without having to go back to the webpage however. If you need other languages, then go to the webpage you downloaded Aspell from to get them.
  3. After your Aspell installation is finished, double click on the dictionary file you downloaded in the last step to install it as well. Install it with all defaults as long as you did the same with the install directories for Aspell as well. Click, click, click and it's installed!

Notes: When you are done with the three simple installation steps, open Notepad++, click on plugins in the top menu and select "spell checker" from the drop-down menu. I was impressed with the easy installation even though it was missing a link and there wasn't much documentation. It took less than five minutes to do, so this is an easy thing to do that will save you tons of headaches in the future.

I do have one complaint with the functionality and did find one apparent bug right off the bat. The issue that stuck out to me the most was that it didn't automatically suggest the most likely correct spelling of the misspelled words. It did provide a list of most likely alternatives, but there is a field that is supposed to have the most likely correct spelling and that field is always populated with the misspelled word instead of the correct spelling. Then I noticed there was a button that read "learn", so I figured it had to be taught this and there is where I found the apparent bug. When I pressed the Learn button, it gave me an error and didn't do anything constructive. This is new to me, so perhaps I will report back later on this blog when I find a solution to the bug and/or functionality issue. Even with this minor bug and issue, it still performs well and gets the job done, so overall, I am happy to have a spell checker for Notepad++ now!

As promised, I am back to solve the issues with Aspell mentioned in this tutorial. Here is how to fix the error:

Ensure that the security settings of the "C:/Program Files (x86)/Aspell" folder for the current user allow for modifying and writing

Locate your Aspell directory by the error itself. Mine was in "C:/Program Files (x86)/Aspell" as the error indicates. From the Aspell directory do the following fixes:

  1. Right Click on the Aspell directory and select "Properties". Then select the "Security" tab and click on the "Edit" button to alter permissions.
  2. Click on the username that you use Notepad++ with then click the Allow column for "Full Control" for that user in the permissions box. Hit apply then okay twice.
  3. Now enter the Aspell/dictionary directory and give any files with .pws or extension in the dictionary folder write permissions for your username. Using the same technique as in the first couple steps above.
  4. Next open up Notepad++ or notepad and create a new text file then copy and paste the following into it and save it as en.pws: personal_ws-1.1 en 2
    µÄ
  5. Click the encoding option in the top toolbar of notepad and make sure that ANSI is the coding type and save the document to c:/Program Files(x86)/Aspell or wherever your Aspell was installed.
  6. Now go back to notepad or Notepad++ and create yet another text file and paste the following green text into the first line and save it as an ANSI encoded file into the same Aspell directory, but name this file en.prepl: personal_repl-1.1 en 0 
  7. close and restart Notepad++ and try out the program with the Aspell plugin again and you will find it should be all working now!