LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 09-28-2009, 01:20 PM   #1
saurin
Member
 
Registered: Aug 2008
Posts: 49

Rep: Reputation: 0
vim align c file


I want to align c file which is randomly written.
I use the command gg=G, which align the entire c
file but unable to adjust within 80 colums.
i set the textwidth 80 using following command
:set textwidth=80
but unable to align file vertically.

Would somebody please help me to find the solution
 
Old 09-28-2009, 02:42 PM   #2
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

Rep: Reputation: 46
I'm not sure what you are looking for, but a program that might help is called "indent". There is a -l option which sets the maximum line length. This program is designed to correctly indent (format) programs written in C to make them more readable. Try "man indent" for more details.
 
Old 09-28-2009, 06:14 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,356

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
You may want the wrap and wrapmargin options http://www.ph.unimelb.edu.au/~ssk/vim/options.html
 
Old 01-03-2010, 04:35 AM   #4
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
Quote:
Originally Posted by saurin View Post
I want to align c file which is randomly written.
I use the command gg=G, which align the entire c
file but unable to adjust within 80 colums.
i set the textwidth 80 using following command
:set textwidth=80
but unable to align file vertically.

Would somebody please help me to find the solution
Code:
:set indent plugin on
:set textwidth=80
Now
Code:
gg=G
 
Old 01-03-2010, 03:42 PM   #5
whk
Member
 
Registered: Jun 2005
Posts: 202

Rep: Reputation: 35
:set paste
before you copy/paste anything
:set nopaste
to end it
hths
 
  


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
vim file.tex !latex file.tex & pdfdvi file.dvi & xpdf -remote sname -reload Mol_Bolom Linux - General 0 07-09-2009 07:46 PM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 11:46 AM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
vim always says swap file already exists for a particular file leftty Linux - Software 1 09-13-2008 01:53 PM
Vim cc file template Penguin of Wonder Programming 4 10-10-2006 05:28 PM


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