Re: pulling text to the right?

2007-03-01 Thread Lev Lvovsky


On Feb 27, 2007, at 6:57 AM, Charles E Campbell Jr wrote:


Lev Lvovsky wrote:

I'm sure there's a fancy word for this, but is there any way to  
pull  text to the right?


suppose I have the following:

 COL1  INT,
 COL2  INT,
 COL3   INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do  
that,  I need to put the cursor behind "COL3", hit space several  
times, and  then align "INT" with the other "INTs".  Can I put my  
cursor to the  right of "COL3", and pull it over to "INT" on the  
right?



It sounds like you're interested in aligning text.  For that may I  
suggest looking into Align.vim (and AlignMaps.vim, which come  
together).

To do the alignment, assuming that you're using spaces as delimiters:


All's I have to say in RE to Align.vim is:

"Wow".

thanks Charles!

-lev


Re: pulling text to the right?

2007-03-01 Thread Matthew Winn
On Wed, 28 Feb 2007 12:55:23 -0800, Lev Lvovsky <[EMAIL PROTECTED]>
wrote:

> That sort of does what I want, but it ends up moving the "INT" right  
> along with it.  I guess what I'm looking for is a combination of key  
> strokes:
> 
>COL1  INT,
>COL2  INT,
>COL3 INT,
>^
> 
> I put my cursor at the column of the '^', on line 3 and press that  
> keystroke, which would simultaneously go to the beginning of the  
> line, , go back to the '^', and '' from that position, to  
> bring the "INT" back a space.
> 
> The real goal of this formatting is to create text that looks like this:
> 
> SOME_COL  VARCHAR(32),
>   SOME_COL12  INT,
>   BLAH_BLAH1  BOOL,
> 
> I would suppose that this can be made with a vim function right?

I'd think it was likely, given that two days ago I posted a mapping
that does exactly that. In fact you can do it exactly as you describe
above by mapping something to "maI `ax". (Unlike my first try,
this one won't stop when it runs out of spaces under the cursor.)

-- 
Matthew Winn


Re: pulling text to the right?

2007-02-28 Thread Lev Lvovsky

Thank you for everyone's help so far (reply below)

On Feb 27, 2007, at 12:48 AM, Yakov Lerner wrote:


On 2/26/07, Lev Lvovsky <[EMAIL PROTECTED]> wrote:

I'm sure there's a fancy word for this, but is there any way to pull
text to the right?

suppose I have the following:

  COL1  INT,
  COL2  INT,
  COL3 INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,
I need to put the cursor behind "COL3", hit space several times, and
then align "INT" with the other "INTs".  Can I put my cursor to the
right of "COL3", and pull it over to "INT" on the right?


Try >> in normal mode. :help >, :help <, :help 'shiftwidth'


That sort of does what I want, but it ends up moving the "INT" right  
along with it.  I guess what I'm looking for is a combination of key  
strokes:


  COL1  INT,
  COL2  INT,
  COL3 INT,
  ^

I put my cursor at the column of the '^', on line 3 and press that  
keystroke, which would simultaneously go to the beginning of the  
line, , go back to the '^', and '' from that position, to  
bring the "INT" back a space.


The real goal of this formatting is to create text that looks like this:

   SOME_COL  VARCHAR(32),
 SOME_COL12  INT,
 BLAH_BLAH1  BOOL,

I would suppose that this can be made with a vim function right?  Any  
good tutorials on them?


thank you!
-lev



Re: pulling text to the right?

2007-02-27 Thread Kim Schulz
On Tue, 27 Feb 2007 17:10:40 -0500
Charles E Campbell Jr <[EMAIL PROTECTED]> wrote:

> So everything lined up.  Of course, when I used my mouse to pick up
> your text, it was composed of all spaces.  Does your original happen
> to have a mixture of tabs and spaces?
> 
> Besides, this text is looking rather like a declaration set.  There's
> a map specifically supporting that:
> \adec

seems like the script wasn't loaded propertly. After restarting gvim,
both \tsp and \adec worked  (the latter one having the best result). 
great script which I am sure I will get to use alot. 

-- 
Kim Schulz| Private :  http://www.schulz.dk
[EMAIL PROTECTED] | Business:  http://www.devteam.dk
+45 5190 4262 | Sparetime: http://www.fundanemt.com


Re: pulling text to the right?

2007-02-27 Thread Charles E Campbell Jr

Kim Schulz wrote:


I just tested it to see if I could get it to work, but I have some
problems. 
I inserted the following

  int foo;
  uint8_t bar;
  TIME   baz;
  int   hello="world;

and then followed you instructions (used \tsp), but the result
afterwards is:
 int foo;
uint8_t bar;
   TIME   baz;
  int   hello="world;

 


What I got with your example:

  int foo;
  uint8_t bar;
  TIMEbaz;
  int hello="world;

So everything lined up.  Of course, when I used my mouse to pick up your 
text, it was composed of all spaces.  Does your original happen to have 
a mixture of tabs and spaces?


Besides, this text is looking rather like a declaration set.  There's a 
map specifically supporting that:

\adec

Regards,
Chip Campbell




Re: pulling text to the right?

2007-02-27 Thread Kim Schulz
On Tue, 27 Feb 2007 09:57:55 -0500
Charles E Campbell Jr <[EMAIL PROTECTED]> wrote:

> Lev Lvovsky wrote:
> 
> > I'm sure there's a fancy word for this, but is there any way to
> > pull text to the right?
> >
> > suppose I have the following:
> >
> >  COL1  INT,
> >  COL2  INT,
> >  COL3   INT,
> >
> > I'd like to get "COL3" aligned to "COL1" and "COL2", but to do
> > that, I need to put the cursor behind "COL3", hit space several
> > times, and then align "INT" with the other "INTs".  Can I put my
> > cursor to the right of "COL3", and pull it over to "INT" on the
> > right?
> 
> 
> It sounds like you're interested in aligning text.  For that may I 
> suggest looking into Align.vim (and AlignMaps.vim, which come
> together). To do the alignment, assuming that you're using spaces as
> delimiters:
> 
>   at the upper right hand corner, type  V
>   move cursor to bottom right hand corner.
>   type \tsp
> 
> If you're using tabs as delimiters, then use \tab instead of \tsp.

I just tested it to see if I could get it to work, but I have some
problems. 
I inserted the following
   int foo;
   uint8_t bar;
   TIME   baz;
   int   hello="world;

and then followed you instructions (used \tsp), but the result
afterwards is:
  int foo;
 uint8_t bar;
TIME   baz;
   int   hello="world;




-- 
Kim Schulz| Private :  http://www.schulz.dk
[EMAIL PROTECTED] | Business:  http://www.devteam.dk
+45 5190 4262 | Sparetime: http://www.fundanemt.com


Re: pulling text to the right?

2007-02-27 Thread Charles E Campbell Jr

Lev Lvovsky wrote:

I'm sure there's a fancy word for this, but is there any way to pull  
text to the right?


suppose I have the following:

 COL1  INT,
 COL2  INT,
 COL3   INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,  
I need to put the cursor behind "COL3", hit space several times, and  
then align "INT" with the other "INTs".  Can I put my cursor to the  
right of "COL3", and pull it over to "INT" on the right?



It sounds like you're interested in aligning text.  For that may I 
suggest looking into Align.vim (and AlignMaps.vim, which come together).

To do the alignment, assuming that you're using spaces as delimiters:

 at the upper right hand corner, type  V
 move cursor to bottom right hand corner.
 type \tsp

If you're using tabs as delimiters, then use \tab instead of \tsp.

=


1. Get an up-to-date version of vimball and Align:

   [vimball]
http://vim.sourceforge.net/scripts/script.php?script_id=1502
 -or-   http://mysite.verizon.net/astronaut/vim/index.html#VimBall
 (the mysite.verizon.net one will be the more recent version)

 [align]
http://mysite.verizon.net/astronaut/vim/index.html#ALIGN

2) Remove the old vimball plugin and install the new one:

   Linux:
   cd /usr/local/share/vim/vim70
   /bin/rm plugin/vimball*.vim autoload/vimball*.vim doc/pi_vimball.txt
   mv (wherever it was downloaded)/vimball.tar.gz .
   gunzip vimball.tar.gz
   tar -xvf vimball.tar

   Windows:
   Under Windows, check your runtimepath to determine where your 
vim 7.0's runtime directories are:


   vim
   :echo &rtp
   :q

   The first directory is likely your personal plugins directory, 
the second one is your vim system directory.


   cd (to your vim system directory)
   del plugin\vimballPlugin.vim
   del autoload\vimball.vim
   del doc\pi_vimball.txt
   ren (wherever)\vimball.tar.gz vimball.tar.gz
   gunzip vimball.tar.gz
   tar -xvf vimball.tar

3) Install a new version of Align:
  vim Align.vba.gz
  :so %
  :q



Re: pulling text to the right?

2007-02-27 Thread cga2000
On Mon, Feb 26, 2007 at 07:30:09PM EST, Lev Lvovsky wrote:
> I'm sure there's a fancy word for this, but is there any way to pull  
> text to the right?
> 
> suppose I have the following:
> 
>  COL1  INT,
>  COL2  INT,
>  COL3INT,
> 
> I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,  
> I need to put the cursor behind "COL3", hit space several times, and  
> then align "INT" with the other "INTs".  Can I put my cursor to the  
> right of "COL3", and pull it over to "INT" on the right?

I have this mapping in my ~/.vimrc that lets me enter spaces while
remaining in "normal" mode:

:nmap  i 

So in the above example I would enter:

G   /* move cursor to last line - COL3 ..*/
3 /* move COL3 three columns to the right  */
e   /* move the cursor to the '3' of COL3*/
l   /* move the cursor to the space after COL3   */
3x  /* delete three spaces to the right of COL3  */

Sounds like a lot of work but all it really adds up to is seven
easy keystrokes and the hands remain positioned on the home row.

Compare with, for instance:


i





.. fifteen keystrokes (and several moves to difficult-to reach keys)

It's obviously not what you were looking for .. but once you get used to
cursor movement commands that go beyond h,j,k,l (or worse .. arrow keys)
it can be done quickly & effortlessly.  

I admit that fluency does require a few months of practice so it's
really for you to decide whether it's worth the trouble.

Thanks,
cga



Re: pulling text to the right?

2007-02-27 Thread Yakov Lerner

On 2/26/07, Lev Lvovsky <[EMAIL PROTECTED]> wrote:

I'm sure there's a fancy word for this, but is there any way to pull
text to the right?

suppose I have the following:

  COL1  INT,
  COL2  INT,
  COL3 INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,
I need to put the cursor behind "COL3", hit space several times, and
then align "INT" with the other "INTs".  Can I put my cursor to the
right of "COL3", and pull it over to "INT" on the right?


Try >> in normal mode. :help >, :help <, :help 'shiftwidth'

Yakov


Re: pulling text to the right?

2007-02-27 Thread Matthew Winn
On Mon, 26 Feb 2007 16:30:09 -0800, Lev Lvovsky <[EMAIL PROTECTED]>
wrote:

> I'm sure there's a fancy word for this, but is there any way to pull  
> text to the right?
> 
> suppose I have the following:
> 
>   COL1  INT,
>   COL2  INT,
>   COL3   INT,
> 
> I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,  
> I need to put the cursor behind "COL3", hit space several times, and  
> then align "INT" with the other "INTs".  Can I put my cursor to the  
> right of "COL3", and pull it over to "INT" on the right?

I wouldn't bother with anything more than basic editing commands for
a single change like this. Just press I (to start inserting to the
left of the COL3), type spaces until the column is aligned, then Esc
kwwj (to put you in the right place for the INT) and dw (to remove the
unwanted spaces).

If you have tabs in the middle of the lines you may also need to press
i and some more spaces because the dw may remove too much.

Alternatively, this crude mapping will pull things over towards the
cursor. It works by transferring one whitespace character from one
side of the COL3 to the other:

:map [whatever] 
:s/^\\(\\s*\\)\\(\\S.\\{-}\\)\\(\\s\\)\\(\\s*\\)\\%#/\\1\\3\\2\\4/``

Debackslashed, that expression is:

s/^\(\s*\)\(\S.\{-}\)\(\s\)\(\s*\)\%#/\1\3\2\4/

That is, match the leading spaces (if any), one or more words,
a single space, and then any additional spaces up to the cursor
position, and replace them but moving the single space to just
before the words.

-- 
Matthew Winn


Re: pulling text to the right?

2007-02-26 Thread durgaprasad jammula
Hi,

If all the lines in a file only contains 2 words [column & int], you can even 
write a one line awk command to indent it.

cat data.txt | awk '{print "   "$1"  "$2}'  > indented_data.txt


- Original Message 
From: A.J.Mechelynck <[EMAIL PROTECTED]>
To: Lev Lvovsky <[EMAIL PROTECTED]>
Cc: vim users list 
Sent: Tuesday, February 27, 2007 8:10:44 AM
Subject: Re: pulling text to the right?

Lev Lvovsky wrote:
> I'm sure there's a fancy word for this, but is there any way to pull 
> text to the right?
> 
> suppose I have the following:
> 
>  COL1  INT,
>  COL2  INT,
>  COL3   INT,
> 
> I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that, I 
> need to put the cursor behind "COL3", hit space several times, and then 
> align "INT" with the other "INTs".  Can I put my cursor to the right of 
> "COL3", and pull it over to "INT" on the right?
> 
> thanks!
> -lev
> 

With 'autoindent' on, place the cursor at the end of the second line in Insert 
mode, hit  to join the lines, then  to break them again. The third 
line will align itself with the second one regardless of how many spaces are 
between the cursor and the first word (try it, you'll see). This won't align 
INT though, but there are several possible ways to do that after COL3 has been 
aligned. One of the fastest of these methods is to drag the mouse across all 
the spaces to be deleted to the left of INT in the third line, then hit .

An alternative possibility would be to write an ad-hoc 'indentextpr' function, 
then reformat the whole file with gggqG -- but I wouldn't do that unless there 
were really many such "misindents" to correct.


Best regards,
Tony.






 

Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091


Re: pulling text to the right?

2007-02-26 Thread A.J.Mechelynck

Lev Lvovsky wrote:
I'm sure there's a fancy word for this, but is there any way to pull 
text to the right?


suppose I have the following:

 COL1  INT,
 COL2  INT,
 COL3   INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that, I 
need to put the cursor behind "COL3", hit space several times, and then 
align "INT" with the other "INTs".  Can I put my cursor to the right of 
"COL3", and pull it over to "INT" on the right?


thanks!
-lev



With 'autoindent' on, place the cursor at the end of the second line in Insert 
mode, hit  to join the lines, then  to break them again. The third 
line will align itself with the second one regardless of how many spaces are 
between the cursor and the first word (try it, you'll see). This won't align 
INT though, but there are several possible ways to do that after COL3 has been 
aligned. One of the fastest of these methods is to drag the mouse across all 
the spaces to be deleted to the left of INT in the third line, then hit .


An alternative possibility would be to write an ad-hoc 'indentextpr' function, 
then reformat the whole file with gggqG -- but I wouldn't do that unless there 
were really many such "misindents" to correct.



Best regards,
Tony.


pulling text to the right?

2007-02-26 Thread Lev Lvovsky
I'm sure there's a fancy word for this, but is there any way to pull  
text to the right?


suppose I have the following:

 COL1  INT,
 COL2  INT,
 COL3  INT,

I'd like to get "COL3" aligned to "COL1" and "COL2", but to do that,  
I need to put the cursor behind "COL3", hit space several times, and  
then align "INT" with the other "INTs".  Can I put my cursor to the  
right of "COL3", and pull it over to "INT" on the right?


thanks!
-lev