I love notepad ++, I use it for rapid prototyping and making minor change to scripts. For full stack development, I use Vs code.
Best thing about notepad++ is its lighting fast and simple. One feature that I want from any editor is ability to run the code as soon as I am done writing. As notepad++ comes with bare-bone feature, that cant be done out of box but its quite simple added shortcuts to run the file in terminal. You just have to added one line of code or if your are not comfortable access program files, you can use GUI to added the shortcuts.
Let make a shortcut to run the python file. I want to run the file when I press Ctrl+R, file should run from current directory not the python parent directory.
GUI
1. Press F5 or go to run>>run
2. Added following line and click save:
cmd /K cd /d "$(CURRENT_DIRECTORY)" & python -i "$(FILE_NAME)"
Explain:
open command line and change the working directory to current file directory than run python script that is currently active.
cmd --> open command line
/K --> keep terminal live
/d --> change file path even if it different drive
$(CURRENT_DIRECTORY) --> get current directory
& --> complete running code before this and than execute the next block
python --> command to run python (you can also give fill path of exe file, this can be any command depending on your file or setting)
-i --> run python in interactive mode
$(FILE_NAME) --> get name of current active file
3. Choose the shortcut
4. All done, you can run file using shortcut or go to run >> <NAME OF SHORTCUT>
One line code:
Open shortcuts.xml from roaming folder of notepad++ which can be found in
C:\Users\<USER NAME>\AppData\Roaming\Notepad++\shortcuts.xml
and added
<Command name="python3" Ctrl="yes" Alt="no" Shift="no" Key="82">cmd /K cd /d "$(CURRENT_DIRECTORY)" & python -i "$(FILE_NAME)"</Command>
You can easily change this to run any type of file by changing python keyword with any exe file or command.
Quote from Book I am reading:
“But the real world doesn't go away. Racism exists. People are getting hurt. And just because it's not happening to you, doesn't mean it's not happening. And at some point you have to choose; black or white, pick a side. You can try to hide from it. You can say, oh I don't take sides, but at some point, life will force you to pick a side”― Trevor Noah, Born a Crime: Stories From a South African Childhood
No comments:
Post a Comment