Opening a text file at a certain line (shortcut)

34,989

Solution 1

You'll need to use the command line option listed in the other answer.

And then add a Shortcut key (aka Hotkey) to that Windows shortcut like so:

  1. Make a shortcut to the program itself. You can do this by right clicking somewhere (desktop is easiest, but it doesn't really matter where) and choosing New -> Shortcut. You can also just find Notepad++ in the Start -> (All) Programs menu, right click on the item, copy it from there, and then paste it.

  2. Right click the new shortcut you've made (not the one in the Start Menu), choose Properties, and then go to the Shortcut tab. In the Target box you'll have something already there like "C:\Program Files (x86)\Notepad++\notepad++.exe" You need to add your file you wish to open after the quote marks, and then -n## (replacing the #s with the line number). The target box should read something like "C:\Program Files (x86)\Notepad++\notepad++.exe" c:\users\username\desktop\test.txt -n73

  3. Stay on the Shortcut tab: there is a box for editing the Shortcut key. Click in there and type a letter. It will automatically add Ctrl+Alt to the front of it, and that is your shortcut key. I'm unsure if you can use any other combination keys for the shortcut key.

Solution 2

You need to use the following command-line option (where "#" represents the line number):

-n#

The complete list of command-line options for Notepad++ is available in the project wiki:

Controlling Notepad++ at startup by passing it Command Line Options

Solution 3

To open multiple files each on a certain line with Notepad++:

// for each file (as command line):
notepad++.exe -multiInst filename -n#
Share:
34,989

Related videos on Youtube

user12816
Author by

user12816

Updated on September 18, 2022

Comments

  • user12816
    user12816 over 1 year

    I would like to define a shortcut key which opens a particular text file at a particular line. My preferred editor is Notepad++, but suggestions involving other editors are welcome.

    How to open multiple files in Notepad++ each at a specific line ?

  • Randolf Richardson
    Randolf Richardson almost 13 years
    +1 for adding the other half of the answer that I didn't, and for providing so much detail. Thanks!
  • Jack Franzen
    Jack Franzen over 7 years
    What about nth character? Unity finds bugs with accuracy, including the character in the line as an variable, how can I open with NP++ on that linr AND character?
  • Xan-Kun Clark-Davis
    Xan-Kun Clark-Davis almost 7 years
    I know it's not the answer to the original question, but it was the answer to my questiion :-)