LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2010, 01:30 PM   #1
networkingnub
LQ Newbie
 
Registered: Jul 2009
Posts: 16

Rep: Reputation: 0
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. :-(
 
Old 01-19-2010, 01:39 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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.
 
Old 01-19-2010, 06:06 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Putty logs me out / Putty throws me out after I log in ytd Linux - General 15 08-09-2009 04:03 AM
Formating Eugney Linux - Newbie 2 05-02-2005 04:50 AM
formating mfds Linux - Software 7 04-14-2004 12:15 PM
formating Galilee Linux - Software 2 10-01-2003 12:23 AM
formating.... s9722 Linux - Hardware 10 06-17-2003 01:51 PM


All times are GMT -5. The time now is 03:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration