LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Putty VI and Formating (https://www.linuxquestions.org/questions/linux-newbie-8/putty-vi-and-formating-783271/)

networkingnub 01-19-2010 12:30 PM

Putty VI and Formating
 
I have been given some instructions in Vi to format some data. Since I'm new I was basically asked to hit ESC in Vi and then type the following in the on the bottom

:1
:$s/,/CTRL-V then while holding down CTRL press M/g

This would format a wall of text into a readable page.


I was wondering if:

a) There was a place I could go to online to learn what the :$s,/,/ symbols and characters where doing

b) I made a mistake once and now some of the characters in the file are highlighted in yellow. I was wondering if we could turn that off or reset the file....sorry my jargon is brutal. :-(

acid_kewpie 01-19-2010 12:39 PM

well the s// stuff ia a regular expression, there are millions of google hits for regular expression tutorials (Also called a regex or regexp)

being in yellow means you searched for it. e.g. in vi hitting /bum will search for bum and highlight all occurrences in yellow. Personally i just search for something that it won't find, e.g. /ewrdhjgklhjg to clear it, but any vi tutorial will tell you the proper way to clear it.

chrism01 01-19-2010 05:06 PM

What are you trying to do? It looks like you are trying to convert commas to newlines, in which case it's

Code:

:1,$s/,/ctrl-v ctrl-m/g
which means from line 1 to last line ($), substitute comma with Ctrl-V Ctrl-M (ie a new line). Do not put the space between ctrl-v ctrl-m, that's just to make it easier for you to read. The 'g' on the end means all occurrences on each line. By default it would only match/amend the first occurrence on each line.
The vim docs are at http://www.vim.org/ and are also on your system somewhere eg /usr/share/vim/vim62/doc (62 = version 6.2 : YMMV).


All times are GMT -5. The time now is 01:56 PM.