LinuxQuestions.org
Visit Jeremy's Blog.
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 08-03-2008, 12:07 PM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
vi editor problem


Hi everybody,

I am working on RHEL 4es. I use vi editor for text editing. We have long length data files. To view the file without wrapping i give the command ' set nowrap ' everytime.
Typing this lengthy command everytime is boring. Is there any short cut to cut short this command.
Some times i open the files with vimdiff command. But i was told that this command may currupt the file.
Is it true? Kindly help me.
 
Old 08-03-2008, 12:23 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Look for the files ~/.vimrc and ~/.exec

Add the line:

set nowrap

To the first if you have that, otherwise the second. The command is compatible with both vi an vim.

I don't about your vimdiff corruption question.
 
Old 08-03-2008, 12:34 PM   #3
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
editing the .vimrc will permanently open all the files with nowrap. But i dont want this. i want a short cut at vi editor i.e., at : instead of typing the lengthy set nowrap command i want to type a simple word... like :sn.
 
Old 08-03-2008, 12:57 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Create a map:

map <F1> :set nowrap<CR>

This one maps the F1 function key to set nowrap for you.
 
Old 08-05-2008, 08:42 AM   #5
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Kindly guide how to map. I am a newbie for mapping a key.

what i understood is...

at command prompt (in vi)

:map <press f1 key> :set nowrap<here what is CR?>
 
Old 08-05-2008, 09:28 AM   #6
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
CR=carriage rtn aka enter key....
 
Old 08-07-2008, 09:30 PM   #7
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
after mapping its working superbly...but when i exit the vi editor...its gone... again i have to map it when i enter freshly into the vi editor... Guide me to map the key permanently.... or some other hint... or shortcut..
 
Old 08-07-2008, 09:59 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Add any maps or settings you want in each edit session to your .vimrc or .exrc file.
 
Old 08-08-2008, 02:38 AM   #9
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
Err, in your post #3, you said you didn't want that though ....
 
Old 08-08-2008, 02:44 AM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
I think the OP didn't want set nowrap, but is ok with a mapping allowing wrap disabling on demand.
 
Old 08-08-2008, 03:41 AM   #11
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
My mistake..
 
Old 08-08-2008, 11:52 PM   #12
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
Hey! i am unable to find .vimrc in my system(RHEL4ES). We have a separate user like mainsys. In this all our programs files are loaded under prog directory. when i login to mainsys the default path is like this /usr2/project/mainsys/prog. I could find .vimrc of root. But did not use it regularly. how to find .vimrc of mainsys user (group is mainsysgrp)
 
Old 08-09-2008, 12:10 AM   #13
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Just run:

vi $HOME/.vimrc

and add your mappings, then save the file.
 
  


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
vi editor problem sajith Programming 6 08-18-2014 08:46 AM
vi editor problem soumalya Linux - Desktop 11 08-12-2008 01:15 AM
Problem in vi editor init_linux Linux - General 10 09-09-2005 02:40 AM
problem with Vi Editor sailu_mvn Linux - Software 1 08-09-2005 08:27 AM
Problem with the EDITOR variable objorkum Slackware 2 10-19-2004 04:29 PM


All times are GMT -5. The time now is 06:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration