LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-22-2006, 09:28 AM   #1
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Rep: Reputation: 47
How to highlight text in vi editor


I need some help from our experts about the vi editor. I used it everyday.

If you write letter using the wordprocessor, you can make certain sentences or passages in different colors.

I want to do the same thing in the vi editor. I would like to make some sentences with bigger font size.

The reason is I want to highlight certain facts in my letters.

These things are so easy in your wordprocessor. I use the Open Office wordprocessor.

Please tell me how to make changes to certain sentences in vi editor.
This may be an impossible task.
Your comments are welcome.
 
Old 07-22-2006, 09:56 AM   #2
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Vi isn't a word processor, it is a text editor. Think of vi as notepad on steriods. vi is the wrong tool for your specific purpose, you should stick with a word processor. You can of course learn a markup language such as latex and write your letters in vi and use latex commands to specify formatting.

Reference: http://www.latex-project.org/
 
Old 07-22-2006, 10:57 AM   #3
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Thanks phil for taking time to reply me. This is for the first time I heard a bout LaTeX.

It may be already installed on my Linux system. I am using Mandriva Linux 2006 version. It is a 64 bit program.

Do you know how to find out whether it is installed by default?
 
Old 07-22-2006, 11:25 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,788

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
That depends too on the format of the file you are editing.

If this is html, you can use the font tag, eg:
Code:
normal text <font color="red">some red text</font> normal text again
If it is plain text to be displayed in a terminal, you can use ansi escape sequences, eg:
Code:
normal text  ^[[31msome red text^[[31m normal text again
Unfortunately, vi (or vim) won't assist you entering these tags or sequences.
 
Old 07-22-2006, 11:32 AM   #5
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Just to make it clear vi won't then render the html or interpret the shell escape commands, they will always appear as jlliagre wrote them. However a browser will render the html and you'll get your formatted text.

In the same way once you have written your latex source file it needs compiling into some format of your choosing.

I'm unfamiliar with Mandrake, use your package manager tools to find out if it is installed.
 
Old 07-22-2006, 12:00 PM   #6
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
I thank both of you for taking time to reply me.

I always write a small note using the vi editor. For example, this linuxquestions.org website's username and the password is stored in a vi file.

Some files are just 4 or 5 lines. Some are 2 or 3 page long letters. So I want to highlight some sentences in those files.

I find the vi is very convenient. I have been using it for more than 5 years.

I know the files of html nature works fine to write big or colored letters. I have been writing webpages or rather html pages using the vi editor.

As phil mentioned, the vi is not a wordprocessor. It is a note-pad.

The alternative may be that I wrote everything using html format. That is rather cumbersome. I need something quick. It takes time to write those html tags and related stuff.

I never learnt to work with the vim program. Is it better than the vi editor?
Has it better function than the vi editor?

On the other hand, I can't use the simple 'cat' command to see all the highlights in the vi editor.

As phil mentioned, I must use the webbrowser to see the html pages. That is cumbersome.

Last edited by Gins; 07-22-2006 at 12:04 PM.
 
Old 07-22-2006, 12:48 PM   #7
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Maybe this will help you understand:

Write a letter in openoffice, or some other word processor and add colours, different fonts and sizes to it. Save it as an rtf "Rich Text Format" file . Go and open that file in vi. Other document formats will not work because they are saved in a binary format.

vi just works with plain text documents, it knows nothing of formatting, colours and what have you. When you write your document in a wordprocessor all the formatting must be saved along with the actual text as demostrated by the above test. vim does the same job as vi, it just has more features, but none that make it act like a wordprocessor.

You either need to learn a markup language and in vi use the markup tags to specify the structure of your document, or use a word processor and WYSIWYG techniques.

Edit: Again cat just deals with plain text, it reads a character from a file and prints it on stdout (normally your console). OK its a little more complex than that but thats beyond the scope of this thread, but it does not parse the file for formatting instructions.

Last edited by phil.d.g; 07-22-2006 at 12:54 PM.
 
Old 07-22-2006, 01:23 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,788

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I'm using elvis instead of vim as my preferred vi clone, it has the ability to properly render some text formats like html, tex and nroff manual pages.
You still need to enter the formatting commands manually though.
 
Old 07-22-2006, 01:36 PM   #9
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Thanks Phil for the reply.

I wrote a letter using the Open Office and saved as a .rtf file.

I named it ' Rubbish2001.rtf '

Then I opened it on the vi editor. Please see the following.

\hr20\min24}{\revtim\yr2006\mo7\dy22\hr20\min26}{\printim\yr1601\mo1\dy1\hr0\min0}{\comment StarWriter}{\vern6450}}\deftab709
{\*\pgdsctbl
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgd scnxt0 Default;}}
\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\pgwsxn12240\pghsxn158 40\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aft nrstcont\aftnstart1\aftnnrlc
\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang255\ltrch\dbch\af3\afs2 4\langfe255\loch\f0\fs24\lang1033
\par
\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs40\lang255\ltrch\dbch\af3\afs4 0\langfe255\loch\f0\fs40\lang1033 {\loch\f0\fs40\lang1033\i0\b0 Ffjf\'f6lfj\'f6lsfk\'f6ldsf\'f6k\'f6k\'f6}
\par
\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang255\ltrch\dbch\af3\afs2 4\langfe255\loch\f0\fs24\lang1033 {\loch\f0\fs24\lang1033\i0\b0 jfsjflsfdfls}
\par
\par \pard\plain \ltrpar\s1\cf2{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang255\ltrch\dbch\af3\afs2 4\langfe255\loch\f0\fs24\lang1033 {\loch\f0\fs24\lang1033\i0\b0 fms\'f6fdm\'f6dlsaf\'f6ds}
\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang255\ltrch\dbch\af3\afs2 4\langfe255\loch\f0\fs24\lang1033
\par \pard\plain \ltrpar\s1\cf3{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs32\lang255\ab\ltrch\dbch\af3\a fs32\langfe255\ab\loch\f2\fs32\lang1033\b {\loch\f2\fs32\lang1033\i0\b f\'f6\'e4f\'e4\'f6dsfl\'e4sdf\'e4'sdf'ds'\'e4s}
\par
\par
\par
\par }
~
"Rubbish20001.rtf" 26L, 2975C

-----------------------------------------

It saved as a binary file though I saved as a .rtf file.
 
Old 07-22-2006, 01:54 PM   #10
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Nope, thats right. If you scroll down you'll start to see the text you entered in OpenOffice. Those tags and keywords are instructions to specify the structure and formatting of your document. As you can see vi hasn't interpreted them and formatted your text appropriately it just shows the keywords as text.

Hold on, did you write nonsense in your document. Are these strings from it:
Quote:
Ffjf
Quote:
jfsjflsfdfls
OK, this definately is a string from it
Quote:
föäfäödsfläsdfä'sdf'ds'äs
Using non-ascii characters and random strings makes spotting your text even harder.

Last edited by phil.d.g; 07-22-2006 at 02:10 PM.
 
Old 07-22-2006, 02:21 PM   #11
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Quote:
Originally Posted by jlliagre
I'm using elvis instead of vim as my preferred vi clone, it has the ability to properly render some text formats like html, tex and nroff manual pages.
I did not know that. I don't know the roadmap for elvis but I suppose being able to render some formats is half way to having a WYSIWYG editing capacity.
 
Old 07-22-2006, 04:28 PM   #12
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Phil

I wrote nonsense; you are 100% correct. This is a trial. However, now it is too late here. I must sleep. I would attend this again tomorrow.

Are you based in the USA?
 
Old 07-23-2006, 02:16 AM   #13
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
No, England.
 
Old 07-23-2006, 11:24 AM   #14
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Phil

Out of context, I wonder whether it is common to use Open Source operaing systems in England. I mean the home users. Here it is very rare. If I ask 100 people, I wouldn't find a single individual who uses any Open Source at their home computers.

However, I know 2 people who uses Open Source operating systems. One uses Free BSD and the other uses Linux.

I have Windows XP. I look at it once a week.
 
Old 07-23-2006, 01:56 PM   #15
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Well, seeing as your taking your own thread off topic I suppose it doesn't matter

---

I don't really know. Certainly with people I know who do Computer Science degrees it is reasonably popular, but I don't know anyone who uses a computer as a means to an end that uses Linux. However in other parts of England the case may be different, its a funny country like that. When I was at sixth form college (16 to 18 years old) I knew only one person that used Linux.

The rest of my family won't touch my machines, they'll only use Windows.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
text highlight color in openoffice mcd Linux - Software 4 07-28-2010 06:50 PM
DQ: how do you turn off auto-copy when you highlight text in KDE? jetblackz Linux - Newbie 7 05-10-2008 06:23 PM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM
text editor Mig21 Linux - Software 17 07-07-2005 05:27 PM
vi text editor keevitaja Linux - Newbie 4 08-23-2002 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:29 AM.

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
Open Source Consulting | Domain Registration