Solved

Vim Settings

Posted on 2002-07-04
7
202 Views
Last Modified: 2013-12-16
Hi,
   Sorry for asking at the wrong place but the right question :-(. Here goes my question.

    When option "cindent" is set, then some characters like "#" etc. are positioned at the beginning of the line as soon as we insert that.
    I wanted to know that, for other characaters or words, can we do some sort of setting to get them repositioned anywhere in current line as soon as we enter them?
Thanks in advance,
Animesh
0
Comment
Question by:abhishek_p
  • 4
  • 2
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7131142
> .. are positioned at the beginning of the line as soon as we insert that.

DO you mean that the you type in a new line:

abc#

that you end up in:

#bc
0
 

Author Comment

by:abhishek_p
ID: 7131913
No, not exactly... But like this...

Since autoindent option is set and when I press return key, then cursor won't always be on the first column. It'll , in most cases, be in the middle of the line. So at this instance, when I type #, then it goes to
first column.
-> [Firstly]

                    foo[x] = abc;
                    #include

then it , automatically, becomes as,
-> [ secondly. It happens because "cindent" option is set.]

                    foo[x] = abc;
#include                           <---- This goes at the
                                         first column of
                                         the line.


My question is:
 When I type a word or character in the beginning of the line instead of "#include", then I should be able to place it in the beginning of the line.
        So what it would be good to me is, if somebody tells me how "cindent" does this placement for specific character/word?
Thanks and best regards,
0
 
LVL 20

Expert Comment

by:Gns
ID: 7217346
Ah yes, this is specially handled by cindent, since cpp macros with whitespace before the "sharp" isn't meaningful.
So you want to hack up a macro do something similar for any ol' key...
Have a look at the vim help for cindent and cinkeys etc.
In vim, type
:help cindent<Enter>

Might be useful to you.

-- Glenn
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 20

Expert Comment

by:Gns
ID: 7217404
Yup, that should do it.
See (in vim)
:help C-indenting

Should fit your ticket.

-- Glenn
0
 
LVL 20

Accepted Solution

by:
Gns earned 100 total points
ID: 8647823
"10 months late he asks" ... Did it work out for you?

-- Glenn (Who is going through the "real-old-unlocked-questions" he has commented in)
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8654511
-- Glenn, seems you have daylight all night long, and family send to vacation ... :-))
0
 
LVL 20

Expert Comment

by:Gns
ID: 8654773
:-). Not yet... They'll be going at the end of next week... And no, Stockholm really is to far from the arctic circle to get light all night long...
Not like when I studied at Lulea... If you didn't look out a window at noon during the winter, you could easily miss the grayish dusk of day (approximately 1 hour)... And in the summertime... Let's say it wasn't easy sleeping... "Whoever heard of students sleeping, when they could party":-)

-- Glenn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now