Any way to search for text within nano?

449,746

Solution 1

Ctrl + W is the shortcut for searching. The same effect can be achieved by pressing the F6 key. After entering the search term, press Enter. To repeat the search, issue Alt + W, and to search the previous occurrence, press Alt + Q. In this menu, you can select earlier searches using the arrow up/ down keys.

To toggle backwards searching, you need to press Alt + B in the search dialog.

For more shortcuts, press F1

Solution 2

CTRL+W and find your text in nano

Nano Basics Guide

Solution 3

^W (F6) Search for a string or a regular expression

  1. Not in all system work F1 for help page. Try ^G.
  2. Not in all system nano has help page

Yep, it's just help page below. For those who see this message [ Sorry, support for this function has been disabled ] instead of nano help page

^G (F1) Display this help text

^X (F2) Close the current file buffer / Exit from nano

^O (F3) Write the current file to disk

^J (F4) Justify the current paragraph

^R (F5) Insert another file into the current one

^W (F6) Search for a string or a regular expression

^Y (F7) Go to previous screen

^V (F8) Go to next screen

^K (F9) Cut the current line and store it in the cutbuffer

^U (F10) Uncut from the cutbuffer into the current line

^C (F11) Display the position of the cursor

^T (F12) Invoke the spell checker, if available

M-\ (M-|) Go to the first line of the file

M-/ (M-?) Go to the last line of the file

^_ (F13) (M-G) Go to line and column number

^\ (F14) (M-R) Replace a string or a regular expression

^^ (F15) (M-A) Mark text at the cursor position

M-W (F16) Repeat last search

M-^ (M-6) Copy the current line and store it in the cutbuffer

M-} Indent the current line

M-{ Unindent the current line

^F Go forward one character

^B Go back one character

^Space Go forward one word

M-Space Go back one word

^P Go to previous line

^N Go to next line

^A Go to beginning of current line

^E Go to end of current line

M-( (M-9) Go to beginning of paragraph; then of previous paragraph

M-) (M-0) Go just beyond end of paragraph; then of next paragraph

M-] Go to the matching bracket

M-- (M-_) Scroll up one line without scrolling the cursor

M-+ (M-=) Scroll down one line without scrolling the cursor

M-< (M-,) Switch to the previous file buffer

M-> (M-.) Switch to the next file buffer

M-V Insert the next keystroke verbatim

^I Insert a tab at the cursor position

^M Insert a newline at the cursor position

^D Delete the character under the cursor

^H Delete the character to the left of the cursor

M-T Cut from the cursor position to the end of the file

M-J Justify the entire file

M-D Count the number of words, lines, and characters

^L Refresh (redraw) the current screen

^Z Suspend the editor (if suspend is enabled)

(M-X) Help mode enable/disable

(M-C) Constant cursor position display enable/disable

(M-O) Use of one more line for editing enable/disable

(M-S) Smooth scrolling enable/disable

(M-P) Whitespace display enable/disable

(M-Y) Color syntax highlighting enable/disable

(M-H) Smart home key enable/disable

(M-I) Auto indent enable/disable

(M-K) Cut to end enable/disable

(M-L) Long line wrapping enable/disable

(M-Q) Conversion of typed tabs to spaces enable/disable

Solution 4

You can search for text in nano using Ctrl W.

Alt W (or Esc, W) will repeat the find. (Alternatively, leaving the box blank will default to the last text searched for.)

Pressing Ctrl R while in the Find prompt will activate Replace mode.

As of nano 2.8.2 (May 2017), searching also works in nano's Ctrl G help screen.

Share:
449,746

Related videos on Youtube

JD Isaacks
Author by

JD Isaacks

Author of Learn JavaScript Next github/jisaacks twitter/jisaacks jisaacks.com

Updated on September 18, 2022

Comments

  • JD Isaacks
    JD Isaacks over 1 year

    Nano is the editor I use in command prompts.

    When I open a large file I would like to search for some text (think Ctrl + F).

    Is there a way to do this?

    • Alexey Ce
      Alexey Ce over 7 years
      Ctrl + \ is useful for replace. I never noticed, it's there at the bottom of the nano screen.
  • fIwJlxSzApHEZIl
    fIwJlxSzApHEZIl almost 9 years
    Alt + W is closing out the iterm shell for me and not repeating the search on Mac
  • ubuntu_uk_user
    ubuntu_uk_user over 8 years
    Alt-B isn't working for me
  • ubuntu_uk_user
    ubuntu_uk_user over 8 years
    How would you search for a string that occurs multiple times, so loop through highlighting the matched text?
  • Lekensteyn
    Lekensteyn over 8 years
    @ParsaAkbari Your terminal emulator is probably intercepting the keystroke. Try modifying the terminal shortcuts or use a different one. Konsole works for me.
  • Emiel
    Emiel almost 8 years
    If you type ctrl + W again and press enter, you will go to the next item. (But I agree that Alt + W is faster.)
  • Eleanor Zimmermann
    Eleanor Zimmermann over 7 years
    Esc - W did it for me in Mac OS X El Capitan, v10.11.5 thankyou
  • user3757405
    user3757405 over 7 years
    I've discovered recently, a lot of shortcuts tend to work if you press Shift as well, so Alt-Shift-W may work too. (Which makes things a lot easier for repeated searches.)
  • computingfreak
    computingfreak over 7 years
    F6 triggers the same action, and saves a keystroke.
  • Lakshman Pilaka
    Lakshman Pilaka over 6 years
    Alt W is what i was looking for.
  • user3757405
    user3757405 over 6 years
    Note, some terminals grab Alt W, but Alt Shift W should also work
  • TechFanDan
    TechFanDan over 2 years
    In a Citrix window, I found that F6 worked whereas CTRL+W would close the tab in the browser.