LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 11:07 AM   #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, 11:23 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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, 11:34 AM   #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, 11:57 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Create a map:

map <F1> :set nowrap<CR>

This one maps the F1 function key to set nowrap for you.
 
Old 08-05-2008, 07: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, 08:28 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
CR=carriage rtn aka enter key....
 
Old 08-07-2008, 08: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, 08:59 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Add any maps or settings you want in each edit session to your .vimrc or .exrc file.
 
Old 08-08-2008, 01:38 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Err, in your post #3, you said you didn't want that though ....
 
Old 08-08-2008, 01:44 AM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
I think the OP didn't want set nowrap, but is ok with a mapping allowing wrap disabling on demand.
 
Old 08-08-2008, 02:41 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
My mistake..
 
Old 08-08-2008, 10: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-08-2008, 11:10 PM   #13
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Just run:

vi $HOME/.vimrc

and add your mappings, then save the file.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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