LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2009, 04:52 AM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Rep: Reputation: 16
how can load vi / nedit with marked word?


Hi...

anyone know what is the command line to view file (nedit / gvim) with marked word?

Thanks.

Last edited by DoME69; 12-07-2009 at 05:22 AM.
 
Old 12-07-2009, 05:58 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I'm not really sure if this is what you are looking for, but maybe it is:

vi +/marked_word infile

The above command opens infile and places the cursor at the beginning of the line of the first occurrence of marked_word.

Hope this helps.
 
Old 12-07-2009, 06:46 AM   #3
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
Hi...

this in not good for me.
with this command the cursor go to the line of the marked name and not colored the word.
also...

if there are few words the cursor goes to the first line that the word exist.

there is another way to do this?
 
Old 12-07-2009, 07:02 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Still not sure what you are looking for.

1) The coloring of "words" (search patterns) is done by search highlighting. It highlights (colors) all the patterns found, not just the one you jump to. This has nothing to do with opening a file and jumping to a specific word.

Syntax highlighting is in general set in the /etc/vimrc or ~/.vimrc file and looks like this on my machine:

Code:
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif
2) I'm not sure what you mean by this:
Quote:
if there are few words the cursor goes to the first line that the word exist.
When searching for a pattern, the search will stop at the first occurrence it finds. Pressing n in command mode will jump to the second (third etc).

Hope this clears things up a bit.
 
Old 12-07-2009, 07:18 AM   #5
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
This is what i mean...

Example:

-> gvim "LIB" file.txt


the file opened and all the world same to "LIB" is highlighted.

hope its clear now.
 
Old 12-07-2009, 07:43 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

It is clear.

The solution is a combination of my previous 2 asnwers.

1) set up general search highlighting (see point 1 post #4). <- I think this is not set up at the moment
2) start as stated in post #2 (vi +/marked_word infile).

If both are working correctly, the infile should be opened, all marked_word's should be highlighted and the cursor should be at the beginning of the line that contains the marked_word (first instance of that marked_word).

Hope this helps.
 
Old 12-07-2009, 07:59 AM   #7
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
This work on vim...

but i want it to open gui window like gvim.
when i use the -g all highlights are disappear
 
Old 12-07-2009, 08:14 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I never used gvim, but a quick search points out that gvim has its own config file: .gvimrc

Take a look here: 3. Setup gvim init files (highlighting [search and syntax] is mentioned in the example in chap 3.1).

Hope this helps.
 
Old 12-07-2009, 08:40 AM   #9
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
Thanks a lot.
now its work.


 
Old 12-08-2009, 03:22 AM   #10
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
another question from the same issue

how can i marked 2 words in the same command?

(i try to google it and didn't found any solution)
 
Old 12-08-2009, 03:40 AM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Do you want to search for 2 (or more) different words at the same time (and see them highlighted)?
If that is the case:

You can use an OR ( | ) construct, which needs to be escaped. Normally you do (from command mode) /foo and press enter and vi goes to and highlights foo.

If you want to look for foo and bar: /foo\|bar Both foo and bar are highlighted and the cursor will jump to either of the 2 that comes first.

Hope this is what you are looking for
 
Old 12-08-2009, 03:46 AM   #12
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
Thanks again...

i need to add ["] symbol

This is the format:

gvim +/"word1\|word2" file.txt
 
Old 12-08-2009, 03:52 AM   #13
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I didn't realize you did this from the command line, not from within (g)vim itself.

You indeed need to keep the search part together. Using double quotes is probably the easiest, although the following would probably have work as well (it does for vim): gvim +/word1\\\|word2 file.txt
 
Old 12-08-2009, 05:09 AM   #14
DoME69
Member
 
Registered: Jan 2008
Posts: 189

Original Poster
Rep: Reputation: 16
After checking, its also work.

i have another question for setting "gvimrc" file...

when i marked the word "connect"
its highlight another words like... "connect / connection / connect2..."

how can i set the gvimrc to mark only this word?

Thanks again.
 
Old 12-08-2009, 06:08 AM   #15
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I'm not sure if this can be set in the configuration file (I don't think it can, never tried it). It is something that needs to be addresses when construction the regular expression.

This: /\<foo will only look for foo and not foobar or barfoo. It also doesn't matter if foo is at the beginning or end of the line.

Give this a try:

gvim +/\\\<word1 file.txt
or
gvim +/"\<word1" file.txt

Hope this helps.
 
  


Reply



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
print second word in 1st line along with 5th word in all the lines after the first bangaram Programming 5 08-31-2009 03:42 AM
variable length string using GD (word wrap, carriage return, word/character count)? frieza Programming 1 02-14-2009 05:21 PM
Problems Copying & Pasting In Word When Word Closes - Ubuntu davidx Linux - Software 3 10-22-2008 08:21 PM
Nedit Doyley Linux - Newbie 1 05-26-2007 10:35 AM
How do you load KDE Add ons like Word galliar SUSE / openSUSE 1 01-27-2005 01:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:07 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