Hot answers tagged


You can use regular expressions by clicking on this button: The regex for a Tab character is \t.


This command will do it (tested on both Mac OS X Lion and Kubuntu Linux). # Recursively find and replace in files find . -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g' Here's how it works: find . -name '*.txt' finds, in the current directory (.) and below, all files whose names end in .txt | passes the output of that command (a list of ...


You can use :%g!/price/d to delete every line that doesn't contain "price"


How to delete lines without .? Menu "Search" > "Replace" (or Ctrl + H) Set "Find what" to ^[^\.]*\r\n You can replace \r\n with different EOL (End of Line) regular expressions depending on the EOLs in your file (see "I have a different EOL in my file, what can I do?" and "I don't care what EOLs my file uses, what can I do?" below). Clear "Replace with" ...


I don't think your files are corrupted. Your example line looks like it contains regular text with null bytes between each character. This suggests it's a text file that's been encoded in UTF-16 but the byte-order mark is missing from the start of the file. See Suppose I open Notepad, type the word 'filename', ...


Find and Replace (CTRL + H) Search for ~* Replace with whatever. Cheers!


You could try: %s/<CTRL-2>//g (on PC) %s/<CTRL-SHIFT-2>//g (on Mac) where <CTRL-2> means first press down the CTRL on PC, keeping it as pressed down, hit 2, release CTRL. and <CTRL-SHIFT-2> means first press down the control on Mac, keeping it as pressed down, press down shift on Mac, keeping it as pressed down, hit 2, release ...


:g/pattern/ matches all the lines were pattern is found. :v/pattern/ does the opposite. See :h global for more details. You can use it like this: :v/pattern/norm Ipattern not found - <CR> to prepend "pattern not found - " to every line that doesn't have "pattern" or :v/pattern/s/nrettap/pattern to replace "nrettap" with "pattern" on every ...


Within notepad there is no way to use the Find and Replace and target blank lines. Consider Notepad++ and the regex search and replace. You can use \r\n to find blank lines from text files made within Windows, \r for Mac and \n for Linux. I believe a default install actually comes with TextFX to make your life even easier, it has an option to delete blank ...


This actually worked for me within vim: :%s/\%x00//g


The accepted answer is correct, but you won't always have regex at ready. So I present a simpler solution. Ctrl+F – click on tab Mark Set "Find what" to . Check option "Bookmark line" (courtesy of Wrass) Search mode = Normal Click Mark All -> You should see a blue circle next to the bookmarked line numbers. Then navigate to menu Search -> Bookmark -> ...


Please make sure you have a backup in case something goes wrong. In Notepad++ go to Search → Replace In the Find What textbox paste the following: youtubehd:\w\w\w\w\w\w\w\w In the Replace With textbox paste the following: youtubehd Ensure that Search Mode is set to Regular expression Click Replace All Thanks to KCotreau for pointing out that search ...


grepWin (not to be confused with Windows Grep) can do this. It supports text-based search and replace, as well as regular expression search and replace: grepWin is free and open source.


vbScript should do it for you. Create a file called "rename_underscores.vbs" containing the following. Set objFso = CreateObject("Scripting.FileSystemObject") Set Folder = objFSO.GetFolder("c:\test\") For Each File In Folder.Files sNewFile = File.Name sNewFile = Replace(sNewFile,"_"," ") if (sNewFile<>File.Name) then File.Move(...


I've written a free command line tool for Windows to do this. It's called rxrepl, it supports Unicode and file search. Some may find it a useful tool. rxrepl is a Microsoft Windows command line tool to search and replace text in text files using Perl compatible regular expressions (PCRE). It has the following features: Search using Perl ...


According to Helixoft: Multiline Search and Replace in Visual Studio you can enable Regular Expressions and then use \n to indicate a new line.


Why don't you select 4 columns and hit c? <C-v> 2j 3l cDone <Esc> Also, you could use :h normal: V 2j :'<,'>norm 7lRDone <Esc>


With your sample text in a file named sql, the following pattern: $ sed 'N; s/,\n FULLTEXT.*//' sql produces: CREATE TABLE `table` ( `id` int(10) NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `description` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @...


Notepad++ allows you to use capture groups in the search regex, and then refer to those in the replacement. so, use the search term ([0-9])\t([0-9]). The parentheses tell Notepad++ to "capture" the part of the text that matches that part of the regex - in this case, the numbers before and after the tab. In your replacement expression, refer to those ...


Yes you can, I just tried to record a new macro, did a search and replace and it succesfully saved the action so when I played the macro, it did the same search and replace action. I am not an expert at Notepad++ Macros, but I am guessing you are... I opened a random file and created a macro called test. It looked for a word called "snip" and replaced it ...


find . -type f -name "*.txt" -exec sed -i'' -e 's/foo/bar/g' {} + This removes the xargs dependency.


At the bottom of the search/replace window you can select the search mode "regular expression", then you can search for CoverLevel="\d\d" the \d means any number, in a regular expression. This searches for two numbers, if you want to search for "one or more numbers" you can use the + quantifier "\d+"


Go to Find (Ctrl+F) -> tab Replace -> click More... -> Special -> End of paragraph. The symbol is ^p. You can use it in both directions. I have MS Office 2007, but it should work in older versions too.


Take a look at Sed. You can easily achieve your goal by only one command line sed -e "s/Text_1/TextA/" -e "s/Text1/TextB/" <your_file.txt>your_file_new.txt


Use the "Extended" setting in the Replace window (not "Regular expression": I'm sure there's a way to do it with Regular expression, but using "Extended" works fine). Enter ".pPrev.\r\n" in the "Find what" field, and leave the "Replace what" field blank. This will include the \r\n characters in the match and delete the whole line.


This would delete all lines that don't contain foo. :g/^\(.*foo\)\@!.*$/d Instead, you could also use :v to reverse the sense of search pattern. :v/\(foo\)/d You can read more about the way :g and :v work here. And more on defining ranges, use of metacharacters etc. for search and replace here.


How do I replace any number of spaces using regular expressions Notepad++ Solution To match one or more space characters: Set "Find what" to + (space followed by +) To match one of more whitespace characters (space, EOL, and tab all count as whitespace): Set "Find what" to \s+ Warning: Using \s+ will match end of line and therefore join multiple ...


That 'symbol' represents a NULL character, with ASCII value 000. It's difficult to remove with vim, try tr -d '\000' < file1 > file2


Since Notepad++ 6.0 it is actually possible without scripts using the following technique: Find: Text_1 and Replace with: Text_A Find: Text2 and Replace with: TextB Find: (Text_1)|(Text2) Replace: (?1Text_A)(?2TextB) The general syntax is: Find: (FindA)|(FindB)|(FindC)... Replace: (?1ReplaceA)(?2ReplaceB)(?3ReplaceC)... ?1 refers to the ...


Fairly basic. Use sed with file globbing. Unless you mean every file in directory and subdirectories? sed -i 's/string1/string2/g' /path_to_dir/* Edit: In the case of literally everything under the directory find /path_to_dir/ -type f -exec sed -i 's/string1/string2/g' '{}' +

Only top voted, non community-wiki answers of a minimum length are eligible