Re: Need a vim hard mode tutorial.

2013-05-13 Thread AK

On 05/13/2013 04:05 AM, Asis Hallab wrote:

Dear Vimers,

2013/5/13 DwigtArmyOfChampions dwightarmyofchampi...@hotmail.com:

If you're not going to search, then are you pretty much always supposed to use 
Ctrl-u and Ctrl-d to navigate through your code, and then when you spot a line 
that needs changed, type :(line number)?


I have been facing the very same problem. For me Vim is about doing
the job of text editing efficiently. So getting to the place you want
to edit should be fast and easy. In spite of all the different
available movement commands I frequently find myself thinking, that in
a particular situation I might had gotten to the place I want to edit
faster using the mouse. After all searching or jumping to a a line
number easily require four to five key strokes.


Because that's pretty much the only way I've been able to move around. What if 
you're in visual mode and you therefore can't use the : to run a command to get 
to the line number you want the visual block to end on?


You can use Gline_number to get to the line you spotted. This works
in visual mode, too.
:h G

I would very much like to read about expert Vim users most used
movement commands and get more efficient in getting to the point I
want to edit.

Cheers!




I made a small modification to Vim source that shows line number from
top of screen instead of from top of file and I've set up two shortucts
for navigation:

Nspace - goes to Nth line from top of screen
space - toggles between 3 positions on current line: 25%, 50% and 75%

The last shortcut uses a small function I wrote.

These two commands that use the same key work much better (for me) than
anything Vim has available built-in.

I thought relative-number mode would be great but in practice it doesn't
seem to work that well. First of all, I don't always remember if I'm
above the line I need to go to or below. This is annoying, because the
action of 'go to this line' is so common it really NEEDS to be a
single-action process, i.e. look up the line, use a single command to go
there.

With relative-number, first you need to make sure if you're above or
below and then use j or k. And it's easy to make a mistake. This is
simply too much overhead for such a simple action.

In addition, a common case is that you might want to go back and forth
between a couple of places in current screen, then it's very helpful if
you just need to remember 2 absolute line locations, e.g. 5 and 25 and
go there directly without having to look them up, irrespective of
current line location.

 -ak

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: YankRing 17.0

2013-04-28 Thread AK

Hi David, one issue I've run into with yankring is
that if I make a recording using q command, it works
fine as I record it, but once I try to play it back,
it gets stuck on a command like dt and yankring asks
for a character.

I use Vim 7.3.

Is there a workaround for this?

Thanks, -ak


On 04/28/2013 07:20 PM, David Fishburn wrote:

YankRing.vim : Maintains a history of previous yanks, changes and deletes
http://www.vim.org/scripts/script.php?script_id=1234

What does it do?

Inspired by the Emacs kill ring.

Allows you to retrieve previous yanks, deletes and changed text and
cycle through them choosing which item you need.  It also works across
Vim instances so they all see the same history.  Useful for sharing
text across instances, including when using Screen in *nix.

For a more descriptive write up, please see the web page.

Thanks for everyone's feedback so far.
If you do try the plugin and find things that bother you, please send
me an email.


What is new?

NF: The yankring_history_dir option can now take a comma separated list.
  First valid directory found will be used (Alex Bel).

NF: YankRing can now monitor inserted text and place it in the ring.
This is disabled by default, but can be enabled either through the
YankRing window or via your .vimrc using the new option:
 g:yankring_record_insert = 1 (Alexandre Viau).

BF: When g:yankring_persist = 0, the YankRing was still reading and
writing to the yankring file (Vladimir Marek).

BF: The YankRing menu entry, Replace with Next, was performing the
Replace with Previous action (Thilo Six).


As usual, feedback good and bad is always welcome.

Enjoy.
David

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google
Groups vim_use group.
To unsubscribe from this group and stop receiving emails from it, send
an email to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: YankRing 17.0

2013-04-28 Thread AK

On 04/28/2013 07:47 PM, David Fishburn wrote:

What version of the YankRing are you using?
:echo g:loaded_yankring



I was using 13 but now I tried with 17 and I get the same
issue.



Also, what version of Vim are you using, I am most concerned with the
patch numbers.
:ver


'10 aug 15; :ver does not show me patch number.




Can you give me a line of text, and the macro you recorded.
I don't see the problem when I record a macro with dt with version 17.0.


e.g. line:

join(SITE_ROOT, templates/forum),

record commands: wdt^P
when executing, I get Yankring: enter character:

 -ak



I am using 7.3.758.

Thanks,
David


On Sun, Apr 28, 2013 at 7:29 PM, AK andrei@gmail.com
mailto:andrei@gmail.com wrote:

Hi David, one issue I've run into with yankring is
that if I make a recording using q command, it works
fine as I record it, but once I try to play it back,
it gets stuck on a command like dt and yankring asks
for a character.

I use Vim 7.3.

Is there a workaround for this?

Thanks, -ak



On 04/28/2013 07:20 PM, David Fishburn wrote:

YankRing.vim : Maintains a history of previous yanks, changes
and deletes
http://www.vim.org/scripts/__script.php?script_id=1234
http://www.vim.org/scripts/script.php?script_id=1234

What does it do?

Inspired by the Emacs kill ring.

Allows you to retrieve previous yanks, deletes and changed text and
cycle through them choosing which item you need.  It also works
across
Vim instances so they all see the same history.  Useful for sharing
text across instances, including when using Screen in *nix.

For a more descriptive write up, please see the web page.

Thanks for everyone's feedback so far.
If you do try the plugin and find things that bother you, please
send
me an email.


What is new?

NF: The yankring_history_dir option can now take a comma
separated list.
   First valid directory found will be used (Alex Bel).

NF: YankRing can now monitor inserted text and place it in the ring.
This is disabled by default, but can be enabled either through the
YankRing window or via your .vimrc using the new option:
  g:yankring_record_insert = 1 (Alexandre Viau).

BF: When g:yankring_persist = 0, the YankRing was still reading and
writing to the yankring file (Vladimir Marek).

BF: The YankRing menu entry, Replace with Next, was performing the
Replace with Previous action (Thilo Six).


As usual, feedback good and bad is always welcome.

Enjoy.
David

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.__php
http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google
Groups vim_use group.
To unsubscribe from this group and stop receiving emails from
it, send
an email to vim_use+unsubscribe@__googlegroups.com
mailto:vim_use%2bunsubscr...@googlegroups.com.
For more options, visit
https://groups.google.com/__groups/opt_out
https://groups.google.com/groups/opt_out.



--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.__php
http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the
Google Groups vim_use group.
To unsubscribe from this group and stop receiving emails from it,
send an email to vim_use+unsubscribe@__googlegroups.com
mailto:vim_use%2bunsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/__groups/opt_out
https://groups.google.com/groups/opt_out.



--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google
Groups vim_use group.
To unsubscribe from this group and stop receiving emails from it, send
an email to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit

Re: clicking to open folds in Gui?

2013-04-02 Thread AK

On 04/02/2013 02:17 PM, Charles Campbell wrote:

I use the following mapping:

nnosilent space:exe 'silent! normal! '.((foldclosed('.')0)?
'zMzx' : 'zc')cr

Its not a click mapping, obviously -- but it makes the space bar a
toggle for the folding under the cursor.  I suppose that instead of
space one could put leftmouse or whatever.



I actually would love to use mouse click for that, BUT:

1. it doesn't work for me, instead moving 1 char to the right, like l.

2. if I get it to work, how can I make it behave as a normal click when
it's not on a fold?

Thanks!  -ak

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Vim on the iPad

2013-03-07 Thread AK

On 12/30/2012 02:33 PM, Jeroen Budts wrote:

On 12/30/2012 07:26 PM, Eric Weir wrote:


I'm likely to purchase an iPad soon and I'm wondering if there have been
any developments since the discussion here back in September.
http://groups.google.com/group/vim_use/browse_frm/month/2012-09 At
that time absence of the escape and control keys, lack of a file system,
and getting files to and from the iPad were the main obstacles.

There were work-arounds for most of them, but most of them, especially
those addressing the lack of a file system, were complicated and
over-the-head of this non-techie user. But that was true of Vim itself
when I first contemplated giving it a try, and now whether there's a way
to get it working on an iPad is a consideration in thinking about
purchasing an iPad.

So I thought I'd check to see if the situation has changed since
September.


I have no idea about the ipad, but I do have some experience in running
Vim on a cheap Android tablet.

For Android there are at least 3 methods:
* vimtouch: which is a touch-optimized version of vim, but restricted by
the normal android rules (no access to most files etc). For me
personally that is rahter useless.
* Terminal IDE: This is a lightweight Unix environment for Android which
includes a fully functional vim.
* Debian Kit: this allows you to install a full (terminal only) Debian
(or Ubuntu) on your Android, which runs together with Android. I really
like this, as it allows you to install most commandline applications
using apt-get, including a full vim (with Python, Ruby) etc, with your
own config, plugins etc.

Considering the keyboard: if you install the 'hackers keyboard' (free
from Google Play) you get a full qwerty keyboard which includes keys
like control and escape.

Not sure if this helps...

Jeroen




One issue I've run into with Vim on stock Android was that I couldn't
get either the Esc or the ctrl-[ key to work from the external key-
board. Both would result in ^@ character.

Is this something that can be fixed? I'm only interested in working
with the external keyboard because I can't understand how people
can use touch keyboard for anything more than 5-8 characters at
a time like typing in a url or something like that.

 -ak

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




conceal HTML tag attributes

2013-02-21 Thread AK

Hi, I would like to accomplish the following:

tag attr1='val' attr2='val' /tag

concealed:

tag /tag


I've mucked around with html.vim syntax file but I can't get anything to
work, not even some very simplified example:

syn match cTag +[a-z]\++ contained conceal containedin=concTag
syn region concTag start=+zz+ end=+zz+ contains=cTag


when I have this text: zz  abc  zz I thought abc would be concealed,
but it's not. Instead, insides of html tags are concealed, which
makes no sense at all. Please help!

 - rainy

--
--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups vim_use group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Swap file already exists

2012-04-10 Thread AK

On 04/10/2012 11:48 AM, Tim Chase wrote:

On 04/10/12 10:19, Ben Fritz wrote:

If you look closely at the swap file exists message, you
should see a line that says modified: no or modified: yes.


Seriously?! I've been using vim for over a decade, hit this message
NUMEROUS times, and have NEVER noticed this line buried in there. This
is so helpful when my work Windows machine decides to spontaneously
reboot overnight on its own whim.

THANK YOU for pointing this out!

-tim





I never noticed that one either. In fact, it would be great if
the whole message Ben wrote was optionally shown above the menu
choices. I think it should also emphasize that, when swap file
is recovered, the original is not deleted, and when the original
opened, swap file is not deleted, because that's not immediately
obvious to a new user.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


How to do a relative paste?

2012-04-10 Thread AK

Hi, how can I paste keeping both the original indent and the indent
of pasted text, but not increasing with each line?

In other words, let's say I have this text:

#slide {
top: 10px;
}

I want to paste it to a location that looks like this:

style
li { float: left }
|
/style

| indicates where it should be pasted. It should end up looking like:

style
li { float: left }
#slide {
top: 10px;
}
/style

It seems like a pretty reasonable default paste behaviour, doesn't it?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: How to do a relative paste?

2012-04-10 Thread AK

On 04/10/2012 06:22 PM, Benjamin R. Haskell wrote:

On Tue, 10 Apr 2012, AK wrote:


Hi, how can I paste keeping both the original indent and the indent of
pasted text, but not increasing with each line?


It sounds like you want ]p

See: :help ]p



That doesn't work for me when pasting from * register. Here's what I end
up with:

#ribbon {
position:absolute;
top:-3px;
left:-15px;
z-index:500;
}

when desired output is:

#ribbon {
position:absolute;
top:-3px;
left:-15px;
z-index:500;
}

-ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Swap file already exists

2012-04-09 Thread AK
I just want to comment that I find the 'swap file already exists' thingy 
to be very un-userfriendly. I think it would be immensely more useful if 
it first showed a text-only diff of the file and swap file,

and then only gave the choices.

There are two issues here:

1. When the choices are given, how in the world am I supposed to know
if the file is newer, or if the swap is newer, or if they're exactly
the same?

2. Once I choose to open the file, why is there no built-in way to
compare them, and to delete the swap file?

Both of these would be solved by showing a diff, or an option to show 
the diff, when the choices are displayed.


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Swap file already exists

2012-04-09 Thread AK

On 04/09/2012 02:49 PM, Gary Johnson wrote:

On 2012-04-09, AK wrote:

I just want to comment that I find the 'swap file already exists'
thingy to be very un-userfriendly. I think it would be immensely more
useful if it first showed a text-only diff of the file and swap file,
and then only gave the choices.


I don't think diffing the two automatically by default would be a
good idea.  It can take a long time to diff large files.



It would be good to have this option in .vimrc, as most people never
edit files so large that diff would take noticeable time.




2. Once I choose to open the file, why is there no built-in way to
compare them, and to delete the swap file?


Diffing the two is pretty easy.  Just use whatever method you
usually use for comparing your editing buffer with the on-disk
version, e.g.:



But I don't have any method for that, because I never need to,
and never do compare editing buffer with on-disk version.

In addition, the swap file may be in a completely different directory
compared to CWD -- for a new user especially, there's a lot of legwork
involved in something that could be handled automatically.

I've occasionally lost my work because of this whole mess.

Usually if vim crashes, I might have 15-20 buffers opened, and for most
of them I need to delete swap file right away because there were no
modifications, and I got used to that and occasionally lost a bit of
not-very-important changes.

At other times I would leave swap files lying around, planning to diff
them at a later time, and then accidentally restore an older swap file.
Again, never lost anything that'd take more than a few minutes to
restore, when I'm dealing with important pieces of code, I'm of course
much more careful, but it's still quite annoying when it happens.

In fact it hasn't happened in the last year or so because I've now
disciplined myself into diffing with the swap file immediately and have
a mapping or a function to delete associated swap file.



 1.  :DiffOrig
 2.  :w !diff % -


I have DiffOrig command but it's not builtin, and I bet most new users
don't have it, and I don't think it's a good command for this scenario
because, if you opened the file, and want to diff it with swap file, it
would not help; and loading from swapfile is something that I feel is
dangerous to do because you're just a write command away from losing the
original file, and I have a write command mapped to an easy key that I
use very often, so I can see myself looking through the file for
changes, being distracted by an email, and then writing it to disk
accidentally.

Unless I misunderstand how this whole thing is supposed to work.

It all seems a lot more complicated than it needs to be. Most commonly,
a user needs to find out if files are different, and if so, what are the
differences, and then he needs an easy menu to make the choice. Right
now vim does it backwards.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Paste whole block by line number

2012-04-04 Thread AK

On 04/04/2012 01:20 PM, Ben Fritz wrote:

On Tuesday, April 3, 2012 10:07:35 PM UTC-5, andrei kulakov wrote:

On 04/03/2012 10:43 PM, horsecandy wrote:

My current method for pasting blocks of code is to select them in visual mode, 
copy/yank them, and paste.  Frequently I see a line or two that I would like to 
copy or move to another line without going through this hassle.  Is there a 
command that can be used to move or copy a whole block of text, specified by 
line number, to some other line-number specified block?




Also: if it's a single line, often it's easiest to type a couple of
first letters, then press ctrl-x ctrl-l which will complete the line.

To use :copy and :move you need to know the line number, so you need to
have :set number option.



Not necessarily. You could have relative numbering turned on, and use a range relative to 
the current line number. Or you could use regular expressions to define the range. Or you 
can use marks (even visual selection, or last modified, etc.) Ranges are much 
more powerful than just absolute line numbers, although admittedly this is how they are 
normally demonstrated.




Good point, I forgot about advanced use of ranges.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: don't want to type _

2012-04-03 Thread AK

On 04/03/2012 01:23 AM, sinbad wrote:

i'm tired of typing underscore_ and -  in insert mode,
is there any way i can get around this. i thought of
using abbr, but it won't work if its in word_like_this.
any thoughts ?

cheers




Swap _ and - in code files via a mapping.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Paste whole block by line number

2012-04-03 Thread AK

On 04/03/2012 10:43 PM, horsecandy wrote:

My current method for pasting blocks of code is to select them in visual mode, 
copy/yank them, and paste.  Frequently I see a line or two that I would like to 
copy or move to another line without going through this hassle.  Is there a 
command that can be used to move or copy a whole block of text, specified by 
line number, to some other line-number specified block?




Please see :help :copy and :help :move   -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Paste whole block by line number

2012-04-03 Thread AK

On 04/03/2012 10:43 PM, horsecandy wrote:

My current method for pasting blocks of code is to select them in visual mode, 
copy/yank them, and paste.  Frequently I see a line or two that I would like to 
copy or move to another line without going through this hassle.  Is there a 
command that can be used to move or copy a whole block of text, specified by 
line number, to some other line-number specified block?




Also: if it's a single line, often it's easiest to type a couple of
first letters, then press ctrl-x ctrl-l which will complete the line.

To use :copy and :move you need to know the line number, so you need to
have :set number option.

  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Bash's vi command line editing mode

2012-03-27 Thread AK

On 03/27/2012 12:03 PM, Charles Campbell wrote:

Ven Tadipatri wrote:

Well...duh..there's an easy fix for this. Just prefix the command with
'#'
Then hit :wq to save it and run it. Still...why does it behave this
way?
Shouldn't I be able to choose not to run the command when I exit
from Bash's vi editing mode?
This is on a Centos 5 machine, and the terminal is a Gnome terminal.


It looks like several of the answers presume you're using vim/gvim
rather than the bash shell's vi-mode (ie. :cq, which doesn't work under
bash shell). Assuming that you actually meant to ask what should you
type while in the shell, not while in vim:

Try 0D

(move cursor to beginning of line, delete contents from cursor to
end-ofline)

Regards,
Chip Campbell




I think dd is easier. The OP said, though, that he is talking about
vim launched from command line.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Bash's vi command line editing mode

2012-03-27 Thread AK

On 03/27/2012 12:27 PM, Charles Campbell wrote:

AK wrote:

On 03/27/2012 12:03 PM, Charles Campbell wrote:

Ven Tadipatri wrote:

Well...duh..there's an easy fix for this. Just prefix the command with
'#'
Then hit :wq to save it and run it. Still...why does it behave this
way?
Shouldn't I be able to choose not to run the command when I exit
from Bash's vi editing mode?
This is on a Centos 5 machine, and the terminal is a Gnome terminal.


It looks like several of the answers presume you're using vim/gvim
rather than the bash shell's vi-mode (ie. :cq, which doesn't work under
bash shell). Assuming that you actually meant to ask what should you
type while in the shell, not while in vim:

Try 0D

(move cursor to beginning of line, delete contents from cursor to
end-ofline)

Regards,
Chip Campbell




I think dd is easier, too. The OP said, though, that he is talking about
vim launched from command line. -ak

Yes, dd will also work; and I agree that its easier to type.

I'm afraid that I've looked over the OP's first two messages and don't
see where vim was launched, though:

Title: Bash's vi command line editing mode
Excerpt: ...but when I do the set -o vi in the bash command line
shell,...
Excerpt: ...if I hit Esc and v on the command line, it goes into vi
editing mode...
Excerpt: ...when I exit the editor it runs the command... (when one
exits Vim, typically it doesn't cause any commands to run)

Regards,
Chip Campbell



When you hit Esc and v in bash (or zsh), it does start the vim
editor, and when you exit it, it puts the buffer in command line,
it doesn't run it immediately but waits for you to press Enter.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Bash's vi command line editing mode

2012-03-27 Thread AK

On 03/27/2012 12:54 PM, Gary Johnson wrote:

On 2012-03-27, AK wrote:


When you hit Esc and v in bash (or zsh), it does start the vim
editor, and when you exit it, it puts the buffer in command line,
it doesn't run it immediately but waits for you to press Enter.


It has never waited for me, using either ksh or bash--the shell has
always immediately executed the contents of the vim buffer as soon
as I exit vim.  I wonder if there is some shell option that controls
that.

Regards,
Gary




I actually use zsh, and that's what it does, I only assumed bash
does the same.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Bash's vi command line editing mode

2012-03-23 Thread AK

On 03/23/2012 11:26 AM, Gary Johnson wrote:

On 2012-03-23, Ven Tadipatri wrote:

Hi,
This may sound like a real newbie question, but when I do the set -o vi
in the bash command line shell, if I hitEsc  and v on the command line,
it goes into vi editing mode. This is kind of cool, as I can exercise
the full editing power of vi, and when I exit the editor it runs the command.
   Unfortunately, sometimes I may have a really powerful/dangerous/unnecessary
command that I've typed, and all I want to do is just cancel, not execute the
command. How do I do this?
   :q! doesn't seem to work, as the command still runs. :wq , well, I don't want
to save anything, I just want to get out of the editor and return to the plain
old bash prompt.
Is this possible? Of course I can always kill the terminal that I'm running
in to avoid running the command as soon as vi exits. Or I can try to press
ctrl+C as fast as possible.
I was hoping for a better alternative.


One way is to exit vim with the :cq command.  See

 :help :cq

That will quit vim with an error code telling bash that the editing
was unsuccessful.

Another is to delete the contents of the vim buffer before saving
and quitting as normal, e.g., dd if there is only one line in the
buffer or ggdG to if there is more than one line, followed by ZZ or
:wq to save and quit.

In this case, you _do_ want to save something because that something
is what bash will execute.

I usually use dd:wq because the :w makes me feel more sure that
the empty buffer has actually been written.

Regards,
Gary





I always ddZZ and I think it's the best approach because this is
not something you might use often and remembering a special :cq
for it makes no sense because everybody knows dd and it works
perfectly well for this use case.

I like it better than :q! because it's easier to type, because
I hardly ever use :q! and dd is more visually explicit, i.e.
you can see this is what will get executed - nothing, with
:q! I think if I take a longer time to edit the command, I
might save it accidentally as I'm working on it, and then
exiting will run the saved version.

I also use the same dd command when I edit the regular command
line and then decide I don't want to run it.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Bash's vi command line editing mode

2012-03-23 Thread AK

On 03/23/2012 08:21 PM, John Little wrote:

Also set -o vi enables a lot of simple vi-like stuff (f.ex.,esc   gets 
you to the fourth previous command).

Regards, John



Numbered commands like 4k work too, of course. I use 2k very often, but 
I don't think I ever use higher numbers than that.  -ak


--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


random :set noet

2012-03-23 Thread AK

I have :set expandtab in my .vimrc but sometimes 'noet' gets set in
other files, for example in .html files. I searched all of my plugins
and I don't see any obvious offenders.

I also tried doing :verbose set et? , but that doesn't tell me where it
was set from, I'm not sure why?

 Thanks!  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: random :set noet

2012-03-23 Thread AK

On 03/23/2012 11:27 PM, Tim Chase wrote:

On 03/23/12 20:45, AK wrote:

I have :set expandtab in my .vimrc but sometimes 'noet' gets set in
other files, for example in .html files. I searched all of my plugins
and I don't see any obvious offenders.

I also tried doing :verbose set et? , but that doesn't tell me where it
was set from, I'm not sure why?


I can't tell you why :verbose set et? doesn't tell you where (that
sounds suspiciously like a bug), but a note at :help 'noet' says that
setting 'cp' can impact things, so I'd scavenge through your startup
files, plugins, and syntax files to see if anything toggles 'cp'.

-tim



Checked for 'cp', it's not being set anywhere..

I should add that this happens very rarely, I edit many files every day
but this happens maybe once in 1-2 months at most. It also never happens
with python files, even though that's what I mostly edit, it definitely
happens to .html and I think also to .vim files. I do edit html and
vim files very often, too, a few times a day on average. I can't spot
any kind of pattern of when or to what file it happens..

  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: random :set noet

2012-03-23 Thread AK

On 03/23/2012 11:54 PM, Tim Chase wrote:

On 03/23/12 22:51, AK wrote:

Checked for 'cp', it's not being set anywhere..

I should add that this happens very rarely


Since it happens rarely and doesn't seem to be easily reproducible, it
would be interesting to see what

:verbose set cp?



It says, set nocompatible from ~/.vim/options.vim, as expected.

This is in the same buffer where I ran into the issue today, I did not 
close or reload it.




returns in addition to the results of

:verbose set et?



simply says 'expandtab', in the same buffer.




to see if there's any correlation to them being (or not-being) what you
expect.

-tim





--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Trouble with :echomsg and html_autoclosetag

2012-03-15 Thread AK

On 03/15/2012 01:05 PM, Ben Fritz wrote:

On Wednesday, March 14, 2012 2:23:49 PM UTC-5, andrei kulakov wrote:

I've always had problems with html_autoclosetag plugin not closing some
tags, e.g. div and b, while it does close other tags, like table, td, p,
etc. Today I finally decided to figure out why it doesn't work.

Looking at the plugin source, I see that main logic is in s:CloseTag().

I made sure that this is the function that gets called in html files by
doing :verbose imap  .

However, when I add debug messages to s:CloseTag(), they do not get
displayed. I've added this line:

  echomsg in CloseTag()

at the top of the function, but after I close a tag in html file and use
:messages command, it's not displayed.

What could be causing this?



If you have an echomsg, and you don't see the message in :messages, then I 
expect the function is just not being called for some reason (or is returning 
before your message).

Did you exit and re-load Vim after modifying the plugin?




Sorry - dumb mistake - there was another script in the directory with a 
similar name. Got it working now.  -ak


--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


vim.org ratings

2012-03-14 Thread AK
I have absolutely no idea what e.g. 116/47 rating for a script on 
vim.org means, I bet 99.9% of new users to the site don't, either, and 
there's no explanation or a link to explanation anywhere near it.


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: vim.org ratings

2012-03-14 Thread AK

On 03/14/2012 12:35 PM, Taylor Hedberg wrote:

AK, Wed 2012-03-14 @ 12:32:44-0400:

I have absolutely no idea what e.g. 116/47 rating for a script on
vim.org means, I bet 99.9% of new users to the site don't, either, and
there's no explanation or a link to explanation anywhere near it.


Yes there is [1]. Not saying it's easy to find or couldn't be improved,
but it exists and is linked from the navigation sidebar.


[1] http://www.vim.org/karma.php



It does not appear in navigation sidebar for me, only on the 'site help'
page.

I think it'd be much better if it was linked from the script karma
box itself. Almost all sites that use ratings use something like
4.5 out of 5 stars, which is self-explanatory (often number or
ratings is shown, as well).

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: vim.org ratings

2012-03-14 Thread AK

On 03/14/2012 12:55 PM, Taylor Hedberg wrote:

AK, Wed 2012-03-14 @ 12:51:47-0400:

It does not appear in navigation sidebar for me, only on the 'site
help' page.


You have to click on Scripts in the sidebar, and then Karma appears
underneath it.



Well, think of how a typical user might try to use it. First, he'd look
at the rating and see it's a ratio. It's a good guess that it may be a
ratio of liked/total, but then he'd see that (for most? scripts) first
number is greater than the last, so that can't be it. If first number is
less than the last, that will likely give one a completely wrong idea of
the rating.

Next the user will look for a link to an explanation near the rating.
It's not there.

Next the user will look at the sidebar for site help link. Scripts
section is not expanded at that point so he will not click on it because
he's not looking for scripts but for help on ratings.

Next he loads site help section. Since he's looking for a section on
scripts and subsection on ratings, he will look for the paragraph with
'Scripts' heading, where he will find no help. At this point he may not
remember that 'karma' was next to the rating so he'll be just looking
for the word 'rating', which is nowhere in the help page.

In other words, if I was trying my best to come up with the most
confusing, least helpful rating system and help for it, I don't think I
could do better than what we have now.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: vim.org ratings

2012-03-14 Thread AK

On 03/14/2012 01:37 PM, Taylor Hedberg wrote:

I agree with you that it's not easy or intuitive to locate the
explanation. I'm not defending the way it is currently designed. Just
stating the facts.

I don't think the rating system itself is bad, just a bit unusual. If it
were easier to locate the explanation, I don't think there would be much
of a problem.



Yeah, sorry - didn't mean to sound so irate.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Trouble with :echomsg and html_autoclosetag

2012-03-14 Thread AK


I've always had problems with html_autoclosetag plugin not closing some
tags, e.g. div and b, while it does close other tags, like table, td, p,
etc. Today I finally decided to figure out why it doesn't work.

Looking at the plugin source, I see that main logic is in s:CloseTag().

I made sure that this is the function that gets called in html files by
doing :verbose imap  .

However, when I add debug messages to s:CloseTag(), they do not get
displayed. I've added this line:

echomsg in CloseTag()

at the top of the function, but after I close a tag in html file and use
:messages command, it's not displayed.

What could be causing this?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Move current line up

2012-03-13 Thread AK

On 03/13/2012 12:39 PM, sc wrote:

On Tue, Mar 13, 2012 at 04:48:43PM +0100, Yannik Sembritzki wrote:

Hello,



is there any pre-defined function which moves the current line up one line
(e.g. ddkP - (only works if you have got a line above and under the line you
want to move)), or has anyone already scripted such a function?


two of my favorite settings in my .vimrc:

nmapsilent  F8  :m+CR
imapsilent  F8  ESC:m+CRa
nmapsilent  S-F8  :m-2CR
imapsilent  S-F8  ESC:m-2CRa
nmapsilent  M-F8  yyp
imapsilent  M-F8  ESCyyp$a

ok, it's more than two, but down (F8) and up (S-F8) are the two i use
the most

hth,

sc




I think alt-k and alt-j are really handy mapping for these
commands.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Vim Script that displays site-packages source python

2012-02-28 Thread AK

On 02/28/2012 10:55 PM, Taylor Hedberg wrote:

Taylor Hedberg, Tue 2012-02-28 @ 22:34:47-0500:




It's quick and dirty, and would probably fail in some corner case, but
would something like this work?

 function! s:PySource(module)
 let path = substitute(a:module, '\v(\w+)\.', '\1/', 'g')
 execute 'view /usr/lib/python2.7/site-packages/' .
   \ substitute(path, '/\w\+$', '', '') .
   \ '.py'
 execute '/\%(class\|def\)' substitute(path, '\v.*/(\w+)$', '\1', '')
 endfunction
 command! -nargs=1 PySource call s:PySource('args')

It may require tweaking to work on your particular system (though it
works on my machine), but this should at least give you an idea of how
you might approach it.


Or it might be easier to just use ctags to create an index of your
site-packages directory, and then use Vim's tag lookup commands to
navigate to the code you want to see.



That's what I do and it works really well.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Suggestion: change in open fold by mouse behaviour

2012-02-28 Thread AK

I think it would be good if clicking to open a fold with a mouse
would jump cursor to the first line of the fold.

Usually, when I open a fold, I want to look at it starting from the top.
When a fold is a few screens wide and current line is under the fold,
the only way to look at the top of it after it's open is to scroll a
few screens up. I run into this all the time. It's much easier to
jump back with ctrl-o than to page up unknown number of times.

What do you guys think?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Applying PEP8 to python sources

2012-02-20 Thread AK

Hi, sometimes I have to deal with poorly formatted python code. Does anyone
have a set of :substitute commands or a small script that prettifies to
at least some of PEP8 guidelines?

Specifically, I would like things like:

x=5 FIX TO: x = 5
BUT: func_call(x=5,
   y=7) should be left as-is

x==y FIX TO: x == y, same for !=
( x, y , z ) FIX TO: (x, y, z); same for [ x, y, z ]
{ x : 1, y: 2 } FIX TO: {x: 1, y: 2}

Lines longer than specified length should be wrapped:

func_call( 
.., 
myvar)

 TO:
func_call( 
..,

  myvar)


I think that covers the most hard to read, annoying to fix things..
  -ak





--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: vim-orgmode

2012-02-02 Thread AK

On 02/02/2012 03:33 PM, Eric Weir wrote:


On Feb 2, 2012, at 12:38 PM, Jan Christoph Ebersbach wrote:


Do you know Emacs' Orgmode? - I assume you don't know it. In the words
of the original developers it's your life in plain text (http://
orgmode.org/).


I know about it from VimOrganizer. I've viewed some of the VimOrganizer videos 
and I believe a video or videos referenced by VimOrgnizer.


Basically Orgmode organizes everything around headings and subheadings
and sub*headings. To create a new heading in vim-orgmode pressS-
CR.


I am really naive, Jan Christoph.S-CR  is shift-CR? If so, it does nothing 
for me. I've tried manually creating an outline using stars but I don't seem to be 
able to do anything on them, either.

Do I need anything in my .vimrc other than filetype plugin indent on? Do I 
need to be in a file with a particular extent?



I haven't used it, but it seems ext should be .org.

How I found out: in ftdetect dir, there is a file org.vim. The name 
should correspond to the extension it applies to.


Also: readme included is README.org.


HTH, -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Better vertical align in code

2012-01-31 Thread AK

On 01/31/2012 10:36 AM, Ben Fritz wrote:

I think it's funny that I read AK's when editing code as when
editing C code, and you seem to have done the same, but apparently
editing code was so self-evidently python for AK that it wasn't even
mentioned in the post.

Proof that everyone sees according to their own experiences, I guess.




I thought of mentioning it at first but decided not to because I
thought it would be the same for all languages where you might want
to align a function call, e.g.

myfunction_name(arg1,
arg2,
arg3,
arg4)


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Better vertical align in code

2012-01-30 Thread AK

Hi, when editing code, my vim setup indents next line to align with a
brace from line above, e.g.:

myvariable_name = (
   |)

But if I manually backspace the line to be closer to start of line:

myvariable_name = (
x = something,
   |)

On carriage return the alignment is still at the brace level. So I need
to fix it manually again. How can I avoid having to do that? I still
would like to keep auto-alignment when I don't fix the line manually.

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Better vertical align in code

2012-01-30 Thread AK

On 01/30/2012 05:38 PM, Gary Johnson wrote:

On 2012-01-30, AK wrote:

Hi, when editing code, my vim setup indents next line to align with a
brace from line above, e.g.:

myvariable_name = (
|)

But if I manually backspace the line to be closer to start of line:

myvariable_name = (
 x = something,
|)

On carriage return the alignment is still at the brace level. So I need
to fix it manually again. How can I avoid having to do that? I still
would like to keep auto-alignment when I don't fix the line manually.


I took a _quick_ look at this but was unable to replicate the
problem.  If I set 'cindent' and type your second example, I get
this:

myvariable_name = (
 x = something,
 )

where Vim aligned that closing parenthesis as shown.

This behavior will depend on the various indent settings.  What
language are you using?  Are you using an indent plugin?  What are
these values:

 :verbose set cindent? cinoptions? indentexpr?



I'm using indent/python.vim and this behaviour is in GetPythonIndent().
I'll just have to hack it.. If I set cindent or cinoptions, is there
a way to set it up to override indentexpr and work as I described?



By the way, () are parentheses, not braces.  Braces are {} and
brackets are [].



{} and [] () are also called curly, square, and round brackets, so I
thought brackets and braces are interchangeable.. guess not!

Thanks,  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Why is caret (^) so slow?

2012-01-29 Thread AK

On 01/29/2012 07:50 PM, Tim Johnson wrote:

I've been using vim for 12 years now :) and am just getting around
to ask this question.

Why is the ^ so slow?
When I press ^, there is a noticeable wait time
before the first non-blank char is selected.

I.E., on every version of vim I have used, I have found this to be
so.
0w is way faster, but may not always be the desired result.



For me, it's instantaneous, and always been like that (I'm using
gvim). What does :map ^ show?  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: What did I do?

2012-01-24 Thread AK

On 01/24/2012 02:23 PM, Chris Lott wrote:

On Tue, Jan 24, 2012 at 4:42 AM, Eric Weireew...@bellsouth.net  wrote:



This is what I do. I also map kk as ESC, which has the double-benefit
that if I forget to get out of insert mode my stupidity just takes me
out of the mode. You might also want to look at
:h tm


I took a look at it. Uncertain of the reason for the reference.


It controls how quickly or slowly you can press the key sequence and
have it trigger the mapping or not.

c
--
Chris Lottch...@chrislott.org




Should be :h 'tm

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: foldtext question

2012-01-15 Thread AK

On 01/15/2012 10:42 AM, Guido Van Hoecke wrote:

Hi,

I want to write a foldtext function where the folded block would not
have the standard +- header with variable nr of dashes, but the exact
text appearing before the fold marker (in casu one or more '{' possibly
followed by a digit). Here it is:

function! MyFoldText()  show the text before the fold marker
 let nr = v:foldend - v:foldstart + 1
 let line = getline(v:foldstart)
 let txt = substitute(line, '{\+\d\=', '('.nr.' lines)', 'g')
 return txt
endfunction

I am expecting erm... hoping that this would preserve the initial
whitespace: a line '\t\t\tsomeText {' would then be displayed as
a folded block with the text '\t\t\tsomeText (nn lines)'.

It is not. I know that the help for 'foldtext' explicitely states
'...Leading white space, // or /* and the text from the 'foldmarker'
and 'commentstring' options is removed. ...'

I was hoping that this comment only applied to the default foldtext
function, but it seems that that is not the case. I would have liked to
have full control over the displayed foldtext.

Is this at all possible?
If so, I'd like to see how it's done.
If it is not the case, wouldn't that be a desirable feature?

With my current indented folded blocks are outdented and
completely break the visual indentation view, such a pitty.

Kind regards,


Guido

--
I must get out of these wet clothes and into a dry Martini.
-- Alexander Woolcott

http://vanhoecke.org ... and go2 places!




It does work for me but I'm dealing with lines that have
leading spaces and I add leading spaces, here is a relevant
snip:

let l = getline(v:foldstart)
let line = substitute(l, '^[ ]*', '', '')
let prefix = repeat(' ', (strlen(l) - strlen(line)))
let c = ''
if l =~ '^\s*class\s' | let c = '(c)--' | endif
let line = prefix . '+--' . c . '  ' . line


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: foldtext question

2012-01-15 Thread AK

On 01/15/2012 01:56 PM, Gary Johnson wrote:

On 2012-01-15, AK wrote:


It does work for me but I'm dealing with lines that have
leading spaces and I add leading spaces, here is a relevant
snip:

 let l = getline(v:foldstart)
 let line = substitute(l, '^[ ]*', '', '')
 let prefix = repeat(' ', (strlen(l) - strlen(line)))
 let c = ''
 if l =~ '^\s*class\s' | let c = '(c)--' | endif
 let line = prefix . '+--' . c . '  ' . line


You can also use the indent() function to get the indentation of the
line directly instead of calculating string lengths, e.g.,

 let n = v:foldend - v:foldstart + 1
 let i = indent(v:foldstart)
 return repeat(' ', i) . +- . v:folddashes .   . n .  lines 

Regards,
Gary




Thanks! I know that now, but I wrote this function a
long time ago..  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Relative number 'jumps'; question about relative numbers

2012-01-13 Thread AK

Now that we have the awesome relative numbers feature,
I often make long jumps using j/k commands, which don't
count as official jumps. Do you use this feature? How
do you go back easily when you jump with something like
37j ?

Secondly, I have a more general question about relative
numbers. They're good for deletions and yanks but I find
that I almost never use them for anything other than
jumps with j/k commands. For that reason, I think it
would be much better if there was an option to number
lines from top of screen and use a single command, relative
to top of screen, not current line, to jump, e.g. 37H,
or map H to space bar.

Then jumping would be much easier because you don't have
to see if you're above or below target line and space is
easier to hit than j or k. And it may even be possible
to add mappings that will do deletion and yanking with
space-jump.

So, I'd like to make a feature request to have an
option to have relative numbers work in this fashion.

Thanks!

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Request for feature upgrade/enhancement.....

2012-01-12 Thread AK

On 01/12/2012 10:44 AM, Ben Fritz wrote:

While it is true that learning VimL is only useful in Vim, whereas
other languages have many uses elsewhere, it is also true that
learning VimL is really just learning Vim. You can use all the same
editing commands you use to interact with the editor, to script it.



I would say that's not an argument against other languages, since
currently supported languages do use the same editing commands
wrapped in a function call. I'm most familiar with Python and
I really appreciate that it's quoting behaviour is nicer, and
the language in general is both cleaner and more powerful. -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Request for feature upgrade/enhancement.....

2012-01-12 Thread AK

On 01/12/2012 01:50 PM, Charles Campbell wrote:

Reid Thompson wrote:

On Thu, 2012-01-12 at 12:07 -0600, sc wrote:

so there might be a faster engine for our scripts

:) heh lets embed tcc and write them all in C


Make lisp the default script engine and import emacs! :O

Look, whenever someone likes a tool, they'd like it used everywhere. Its
the everything looks like a nail because I have a hammer! syndrome.
I've seen this with why learn [some-language: C Java C++ Perl], I think
[Fortran|Cobol|Ada] is fine and dandy and should be used everywhere. In
the present case, substitute {some-language=VimL} and put
Favorite-Other-Scripting-Language in [Fortran|...]'s place.

Points in VimL's favor include: current plugins,
backwards-compatibility, know how to use vim you know how to write much
of vimL.
Against: insular



Also against: lacks in power, a lot of little quirks and special cases.




Points in My-Favorite-Other-Scripting-Language's favor as default:
(please include JavaScript, Perl, Ruby, even lisp, etc) has a dedicated
fan base, those who know it don't need to learn something else,
naturally all the other Favorite-Scripting-Languages (including VimL)
are obviously inferior, we can throw out all the current plugins and
rewrite them in a nifty new Favorite-Other-Scripting-Language, if
compilable then faster



No, I don't think people say my favorite language X is better than
languages like Y, Z, VimL. I think most people would say anything
but VimL, specifically anything general purpose and more or less widely
used, dynamic, competent at text processing. Most would agree, even
if they don't use these languages, that perl, ruby, python and JS are
all fair candidates. I would say perl is somewhat less favorable since
its use is on the decline while the other three are growing. I would
also say JS is less favorable for the reason I already mentioned - most
of even those familiar with it only know a bit of it and in a niche
use case, while ruby and python are used very extensively in in wide
areas of application.

I prefer python as a matter of personal taste but I can take a step
back and say that either would be equally useful, in fact I don't
see any problem if a huge-vim package included both as main
vim scripting languages, is that really a problem with modern hard
drive sizes?



Points against: need to include FOSL with vim, knowing Vim doesn't aid
in knowing FOSL,



Knowing Vim doesn't really aid in learning VimL, except that you can
use normal vim commands in it, but you can use them in other supported
languages, as well, but wrapping them in respective function call.

The difficult part about learning a language, whether it's VimL or
something else, is learning data structures, functions in standard
library, etc. A regular Vim user who knows normal, command and insert
mode commands, will not find learning VimL appreciably easier than
learning python or ruby.


 not backwards compatible, need to throw out current

plugin base (unless one is intending to bloat things by keeping VimL, too)



VimL should definitely stick around for 5-8 years at the least. A bit
more bloat is a small price to pay..



Look: the computing world has become a very-multi-language environment.
Wishing that the One-True-FOSL be supreme is wasteful of wishes.



Currently there are high performance languages used in areas where
they are required, JS is used as a niche language for web pages,
and a handful of general purpose, fast prototyping languages are
used for all other things. It's a bit of a tall order to have
people learn a language to make small changes or extensions to
editor functionality, where a general purpose language would work
perfectly well.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Request for feature upgrade/enhancement.....

2012-01-12 Thread AK

On 01/12/2012 04:53 PM, Erik Falor wrote:

On Thu, Jan 12, 2012 at 08:17:06PM +0100, Marc Weber wrote:

I don't want to offend anybody. Just trying to understand whether
having JS support would change anything. So please consider this thread
as being a test whether such a change would pay off in the long run for
the community.


I'm getting lost in this discussion.  Are we discussing the addition
of a JavaScript interface, or the wholesale replacement of VimL with
JavaScript?

Clearly there is a lot of push-back to the idea of replacing VimL with
another language.  Let me be so bold as to venture to explain why that
is.

There are two components to what we know of as VimL: Ex commands and
expressions (please correct me if I'm wrong about this).



Why are ex commands a part of VimL? They're just user commands.
Sure they can be used directly from VimL but so can normal commands,
and they require an extra keyword only because ex commands are
more often used in VimL.

VimL is user functions, data structures, flow control commands, and
standard library functions. That's what the question is - make
some other language the default, standard, included language
and keep VimL for backwards compatibility for 8 or 10 years
(or more)?



VimL is a domain-specific language in that it is tailored to the
runtime environment inside a text editor.

JavaScript is a domain-specific language in that it is tailored to the
runtime environment inside a web browser.



I don't like JavaScript, but it's light years more powerful than
VimL. JavaScript is a real language that happened to be used
in a domain-specific way, and happened to have more warts than
ruby and python, for historical reasons, but otherwise it's much
better compared to ruby/python/perl than to VimL. I guess it also
doesn't have a mature, standard library, so that's another thing
against it.




JavaScript was created by a web browser company to be used within
their web browsers.  Think about it: before the advent of Node.js,
would anybody take you seriously if you suggested using JavaScript
outside a web browser?



Yes, people talked about using JavaScript as a general purpose
language for a very long time. The main issue, I feel, is that
other languages work rather well and while some prefer javascript,
many prefer other languages, even if javascript were to be standardized,
got a large standard library and so on.





If the expression language were changed to Perl, you'd piss off all of
the Python and Ruby people.  If it were Ruby, you'd piss off the
Pythonistas and Perlers.



Not true at all, anything would be much better than VimL. I happen
to use Python and it would be nice if it was picked for Vim, but
either python, ruby or JS or perl would be fine.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Request for feature upgrade/enhancement.....

2012-01-12 Thread AK

On 01/12/2012 05:10 PM, Michael Ludwig wrote:

If another language, what about the smallest, cleanest and fastest?

http://luajit.org/




I don't have anything against LUA, but I think either of python, ruby,
perl, javascript are used much more widely and have large, mature
libraries (ok true for the first 3 anyway).  I think these are more
significant considerations than being smallest / fastest (it would be
important to compare some practical real world use in vim plugins as to
respective speed, I feel that difference in speed for all of these
languages, for editor scripting, is most likely negligible.

The one real issue is that this would be hard to do..

  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Don't repeat change that is not a change

2011-11-29 Thread AK

Sometimes I accidentally enter insert mode and then
exit it, this causes . command to reset.. Is there
any way to tell vim that, if there was no change,
it does not count as last change?  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Can't find tag!

2011-11-17 Thread AK

On 11/17/2011 05:40 PM, John Little wrote:


On Nov 17, 4:40 am, AKandrei@gmail.com  wrote:

My guess is that if vim sees a tag file with
any tags from current file, it stops searching other tag files and
assumes current tag does not exist?  -ak


(I was hoping someone who'd used tags with python would chime in, I
haven't.  Ironically, I've used python to generate tags.)

No, normally there can be lots of tag files and vim searches them all
if necessary, and it doesn't stop when it finds a tag if you've
used :tselect.

F. ex., in the vim source tree I've put a tags file in every
directory, and in a vim at the top of the tree

:set tags=**/tags
:ts main

I see 17 choices.

Regards, John




Ok, thanks.. at any rate it works fine for me now.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Can't find tag!

2011-11-16 Thread AK

On 11/16/2011 12:29 AM, John Little wrote:



How do I debug something like this?


The tags option has tricky semantics, you may be picking up a tags
file in an unexpected place.  To eliminate this possibility, I'd set
the tags option to point to a single full pathname, f. ex.

:set tags=/tmp/aktags

to be sure which tags file is being used.  Another idea is to run

:echo tagfiles()

and check for surprises.

Regards, John




Thanks, that did work! My guess is that if vim sees a tag file with
any tags from current file, it stops searching other tag files and
assumes current tag does not exist?  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Can't find tag!

2011-11-15 Thread AK

When I do :tag trim_headers , I get 'tag pattern not found' error, even
though this tag is in tags file and tags file is in :set tags.  Some
other tags can be found, though (in the same file), and some more tags
also can't be found. It's a python file and this tag refers to function
definition.

How do I debug something like this?

Thanks!,  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Can't find tag!

2011-11-15 Thread AK

On 11/15/2011 06:59 PM, Andy Wokula wrote:

Am 15.11.2011 23:39, schrieb AK:

When I do :tag trim_headers , I get 'tag pattern not found' error, even
though this tag is in tags file and tags file is in :set tags. Some
other tags can be found, though (in the same file), and some more tags
also can't be found. It's a python file and this tag refers to function
definition.

How do I debug something like this?

Thanks!, -ak


The tag is not found in the tags file?

Vim does a binary search for tags, maybe the tags file isn't properly
sorted?

See 'tagbsearch':
:h 'tbs




I'm generating tags file using default setting for exuberant ctags,
which is supposed to sort them. I tried :set notbs , as well,
but that tag is still not found.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: how to set the contents of a register.

2011-11-12 Thread AK

On 11/12/2011 08:15 AM, Gelonida N wrote:

Hi,

I know how to ge the contents of a register.

reg = vim.eval('@0') fetches for example the contents of register 0



However I did not find a way to set a register to a certain value (from
python)

What would be the command?


Thanks in advance for your help.



command('let @a = abc')   -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: how to set the contents of a register.

2011-11-12 Thread AK

On 11/12/2011 08:57 AM, Gelonida N wrote:

On 11/12/2011 02:29 PM, AK wrote:

On 11/12/2011 08:15 AM, Gelonida N wrote:

Hi,

I know how to ge the contents of a register.

reg = vim.eval('@0') fetches for example the contents of register 0



However I did not find a way to set a register to a certain value (from
python)

What would be the command?


Thanks in advance for your help.



command('let @a = abc')   -ak


Thanks for your answer. I was afraid it will be something like this.

Let's assume I'd like to do something like.

reg = vim.eval('@0')
reg.replace('a','A')
vim.command('let @a = %s' % reg)

This will fail if reg contains funny characters.

So I think I need something like

vim.command('let @a = %s' % vim_escape_function(reg))


What are the rules to escape characters (or is there a
commodity function)?





Try single instead of double quotes.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: how to set the contents of a register.

2011-11-12 Thread AK

On 11/12/2011 05:39 PM, Gelonida N wrote:

On 11/12/2011 11:16 PM, Gelonida N wrote:

On 11/12/2011 03:02 PM, AK wrote:

If I rephrase my question for non python users:

How can I write a vim command, that puts fuloowing five characters in
register '0'

single_quite, double_quote, escape, carriage_return, tab

The escaped python string or above five characters would be.
'\'\x1b\n\t' ( or '\\x1b\n\t )





I came up with following python function to set a register to  an
arbitrar string.

The only thing that I do is to escape the double quote character.
However as I don't know vim scripting well enough I don't know whether
this will be sufficient for all weird characters, that might show up.


def setreg(regname, val):
  sets register regname to string val
 all it does is replace  with \
 and use the 'let' command to set a register
 
 val = val.replace('',r'\')
 vim.command('let @%s = %s' % (regname, val))


def uppercase_a(regname):
  sample command to show the use of setreg() 
 reg_a = vim.eval('@' +  regname)
 reg_a = reg_a.replace('a', 'A')
 setreg('a', reg_a)

With above python function I could now do

:py setreg('a', 'ABC\'\tDEF\nGHI')

and register a would contain the string as specified in python.


Should this do the job or does anybody see potential improvements?




I think that should be fine.. test if it works with unicode text?

I'm not quite sure why you want to set a register contents, typically
you want to put register contents somewhere, so if you're using this
python code, why not have it skip the step and put the text where
you need it, e.g. in a buffer?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: how to set the contents of a register.

2011-11-12 Thread AK

On 11/12/2011 06:49 PM, Gelonida N wrote:

On 11/12/2011 11:46 PM, AK wrote:


def setreg(regname, val):
   sets register regname to string val
  all it does is replace  with \
  and use the 'let' command to set a register
  
  val = val.replace('',r'\')
  vim.command('let @%s = %s' % (regname, val))


def uppercase_a(regname):
   sample command to show the use of setreg() 
  reg_a = vim.eval('@' +  regname)
  reg_a = reg_a.replace('a', 'A')
  setreg('a', reg_a)

With above python function I could now do

:py setreg('a', 'ABC\'\tDEF\nGHI')

and register a would contain the string as specified in python.


Should this do the job or does anybody see potential improvements?




I think that should be fine.. test if it works with unicode text?

Hmm, probably this will fail. good point.
For the time being I'm fine without unicode, meaning
  with buffers containing \n \r \t '  characters
and perhaps some ASCII text as well ;-)


I'm not quite sure why you want to set a register contents, typically
you want to put register contents somewhere, so if you're using this
python code, why not have it skip the step and put the text where
you need it, e.g. in a buffer?



Probably you're right, that what I was asking for is rarely useful.
I just started learning about python scripting within vim.

Knowing almost nothing about vim scripting,
but knowing basic vim commands and knowing python quite well
I was looking for the 'basic' commands, that would allow me to interact
with vim buffers and registers, (probably I still have to learn about
selections / marks)

My thinking was, that if I can access, buffers, registers, marks
and if I can inject key strokes, that I should be able to
write almost anything, that I would like to do (even if there might be
more elegant solutions if I knew more of the vim scripting commands)

One potential use case of setting a register would be to get
text from a selection, buffer, register, process it and dump the result
in the clipboard, such, that I could paste it into another application
(web browser / console window, whatever)
If I understood well I could do this by setting the '+' or '*' register.



I mostly use command, eval, buffers, windows, current.buffer and 
current.line in vim python scripts.


From your earlier message: to get the selection, do something with it
and replace with new text, just cut it to a register using ax normal
command, then simply insert new text at current cursor location.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: how to set the contents of a register.

2011-11-12 Thread AK

On 11/12/2011 08:04 PM, Gelonida N wrote:

On 11/13/2011 01:27 AM, AK wrote:

On 11/12/2011 06:49 PM, Gelonida N wrote:

On 11/12/2011 11:46 PM, AK wrote:
Knowing almost nothing about vim scripting,
but knowing basic vim commands and knowing python quite well
I was looking for the 'basic' commands, that would allow me to interact
with vim buffers and registers, (probably I still have to learn about
selections / marks)

My thinking was, that if I can access, buffers, registers, marks
and if I can inject key strokes, that I should be able to
write almost anything, that I would like to do (even if there might be
more elegant solutions if I knew more of the vim scripting commands)

One potential use case of setting a register would be to get
text from a selection, buffer, register, process it and dump the result
in the clipboard, such, that I could paste it into another application
(web browser / console window, whatever)
If I understood well I could do this by setting the '+' or '*' register.



I mostly use command, eval, buffers, windows, current.buffer and
current.line in vim python scripts.

 From your earlier message: to get the selection, do something with it
and replace with new text, just cut it to a register using ax normal
command, then simply insert new text at current cursor location.


Thanks a lot for your last hint. :-)
This should do the trick (without having to set a register and without
having to escape any string.






By the way I have written a lot of python vim code and I have a
bunch of utility functions that I reuse often. I'll attach
them to this message, see if you might find them useful

But you need to reload it manually if changed, vim won't
reload it if you just have 'from util import *' on top of
a module.

Also, maybe you already thought of this, but I find this
approach handy to expose multiple python functions in
a module:

[in python file]

def delswp(): ...

arg = exist_eval(a:arg)
if arg:
locals()[arg]()


[in .vim plugin]

function! Other(arg)
:pyfile ~/.vim/python/other.py
endfu
nnoremap c-js :call Other(delswp)CR


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
from vim import *

def iexists(var):
return int(eval(exists('%s') % var))

exists = iexists

def exist_eval(var):
if iexists(var): return eval(var)
else: return None

def iexist_eval(var):
x = exist_eval(var)
return None if x==None else int(x)

def ieval(var):
return int(eval(var))

def input(prompt= , strip=True):
i = eval(input('%s ') % prompt)
return i.strip() if i else i

def edit(path):
command(edit %s % path)

def expand(pattern):
return eval(expand('%s') % pattern)

def nextwin(arg=''):
command(call NextWin(%s) % arg)

def bufnr(pattern):
return eval('bufnr(%s)' % pattern)

def buffer(bufnr):
command(buffer %s % bufnr)

def cursor(row_or_tup=None, col=None):
if row_or_tup != None or col != None:
x = row_or_tup if col==None else (row_or_tup, col)
current.window.cursor = row_or_tup if col==None else (row_or_tup, col)
else:
return current.window.cursor

def col(n=None):
return cursor()[1] if n==None else cursor(lnum(), n)

def bcursor(row_or_tup=None, col=None):
Get or set buffer cursor (starting with 0-index).
if row_or_tup is None and  col is None:
c = cursor()
return c[0]-1, c[1]
elif col is None:
cursor(row_or_tup[0]+1, row_or_tup[1])
else:
cursor(row_or_tup+1, col)

def lnum(n=None):
return cursor()[0] if n==None else cursor(n, col())

def blnum(n=None):
Get or set buffer line num (starting with 0-index).
return lnum()-1 if n==None else lnum(n+1)

def indent(ln=None):
if ln==None: ln = lnum()
return int(eval(indent(%s) % ln))

def col(n=None):
return cursor()[1] if n==None else cursor(lnum(), n)

def set(k, v):
command(set %s=%s % (k, v))

def normal(cmd):
command(normal! +cmd)

def search(pat, flags=''):
Search for pattern. flags='b' to search backwards, returns 0 if not found.
if flags:
flags = , '%s' % flags
return int(eval(search('%s'%s) % (pat, flags)))

def search_or_end(pat, flags=''):
Search for `pat`, if not found, go to end of file (or beginning if searching backwards).
flags += 'W'
rc = search(pat, flags)
if not rc:
normal(gg if 'b' in flags else 'G')
return rc

def nwsearch(pat, flags=''):
No-wrap search.
# go to end or beginning of line to ensure we start searching from next line
if not flags : normal('$')
else : normal('0')
return search(pat, flags+'W')

def let(var, val):
command('let %s = %s' % (var, str(val)))

def bufappend(*args):
current.buffer.append(*args)

def getc():
Get char at cursor location.
return current.line[col()]

def wincmd(cmd):
command(wincmd  + cmd

Re: python scripting: get current visual selection

2011-11-11 Thread AK

On 11/11/2011 12:16 PM, Gelonida N wrote:

Hi,

I am rather new to the python scripting module of vim.


I wanted to write a small test script, which
is analyzing all text, that I yanked into named buffers. (not sure if
'named-buffer' is the correct vi term)


Small example

buf_names = 'abcd'
for buf_name in buf_names:
 yank_buffer = vim.?('a') # don't know this command
 yank_buf_len = len(yank_buf) # not sure if len() would be right
 print('yank buffer %s contains %d characters' %
 (buf_name, yank_buf_len))


I found
vim.buffers , but this addresses the edit-buffers and not the 'yank-buffers'

Thanks a lot in advance.



I think this should work:

text = vim.eval(@a)
print len(text)

They are called registers, not yank buffers, and to get their value in 
script, see :h @r


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: python scripting: get current visual selection

2011-11-11 Thread AK

On 11/11/2011 12:49 PM, Gelonida N wrote:

On 11/11/2011 06:39 PM, AK wrote:

On 11/11/2011 12:16 PM, Gelonida N wrote:

Hi,

I am rather new to the python scripting module of vim.


I wanted to write a small test script, which
is analyzing all text, that I yanked into named buffers. (not sure if
'named-buffer' is the correct vi term)





I think this should work:

text = vim.eval(@a)
print len(text)

They are called registers, not yank buffers, and to get their value in
script, see :h @r

  -ak


Thanks a lot AK and Tony,

This helps me a lot. (also getting the nominclature right)

Is there a register for the contents of the current visual selection
(before I pressed 'y') or would I have to fetch this contents
differently (force for example a yank to a register ufront)





It might be in + or * register on unix? But a more reliable way is to
yank it into a register, you can then restore selection using gv 
command: :h gv


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: replacing all characters in the current line?

2011-11-02 Thread AK

On 11/02/2011 12:43 AM, Gary Johnson wrote:

On 2011-11-02, Jose Caballero wrote:

Hi,

this happened to me today. I had a line like this one
===
and I wanted to replace all characters by '-', so I could have something like


I thought I could do it by combining 'g' and 'r' as I understood 'g' is good to
repeat the same command over all chars in a line (like guu or gUU).
However, I was not able to make it work.
I ended up doing something like  :.s/=/-/g

Is not really possible to replace all chars in the current line with a
combination of 'g' and 'r' commands?


Using g,

 :s/./-/g

Using r,

 0v$r-

Or did you mean something else?

Regards,
Gary




In this particular case (no leading indent),
I think Vr- is the easiest command, much easier
than :s. Incidentally, I have a visual mode
mapping to select only the text in current line
and it's often very useful, and I'd use it in
this case if the line was indented.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: ANNC: DrawIt now supports utf-8 box drawing characters

2011-11-02 Thread AK

On 11/02/2011 10:14 PM, Ben Fritz wrote:



On Nov 2, 11:18 am, Charles Campbellcharles.e.campb...@nasa.gov
wrote:

When you're using utf-8 for your file's encoding, you can now use either
of two new commands,

:DIsngl :DIdbl



I have to ask...

I get the DI, but why sngl and dbl?




Maybe single line and double line?  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Mapping shortcuts

2011-10-31 Thread AK

On 10/31/2011 01:06 PM, George Papanikolaou wrote:

I know this is simple. but I can't figure it out by Googling... so.

How can I map a specific keyboard shortcut?
For example, I want to pressCTRL+F to trigger FuzzyFinder instead of typing 
:FuF

Thank you.



:map c-f :Fufcr

:help map

cr there means 'carriage return', i.e. Enter.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Mapping shortcuts

2011-10-31 Thread AK

On 10/31/2011 05:43 PM, Tony Mechelynck wrote:

On 31/10/11 22:03, Benjamin R. Haskell wrote:
[...]

The problem is sometimes that it's too complete, and isn't organized by
the person who's looking for the information (naturally). Google often
cuts through that problem (e.g. by allowing synonyms that the help
writer didn't consider, or terms that aren't fully correct).

[...]

Yes, the Vim help is as complete and as accurate as is humanly possible,
but sometimes it presents a needle-and-haystack problem. This, however,
has been greatly alleviated, first (in Vim 6.2 IIRC) by the :helpgrep
command, and later (Vim 7.x) by the helphelp.txt helpfile, which
centralizes all help on searching help (except the short summary found
by hitting F1) in a single place. Hence the must read in my previous
post.

And I'll add here: even if you do find something which seems relevant
about Vim by Googling or by searching the Wikipedia, always check it
afterwards with the online help, where you may find that your Google
info is perhaps slightly out-of-date, or omits just the corner case
which is giving you problems now.


Best regards,
Tony.



Vim needs a built-in google-like search. Type a few words, get
a list of entries, best matches on top.

helpgrep is not nearly the same thing - it's linewise, not
topic-wise, and it needs exact match, not synonym/tag match;
and out of the box, it does not easily do AND and OR searches
matching any order of words.

Basically, the idea is, Are you already a vim expert and
know exactly the command you need? Boy, do we have a really
great tool to help you find it!

Vim has a really great help system.. one of the best help
systems I've used... for ~2-3,000 lines of content. Unfortunately,
it has 130,000 lines of help.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: how to make 'h,j,k,l' faster ?

2011-10-28 Thread AK

On 10/28/2011 02:05 PM, sc wrote:

On Friday, October 28, 2011 12:23:44 Tim Chase wrote:


On 10/28/11 10:21, Ben Fritz wrote:

I find it very nice to set relative line numbers and use a
count with j/k for down/up movement.



I know about them head-wise, and you're right about it being
easier than keying in the absolute line#, but it's a more
recent feature of vim which hasn't yet made it to my
muscle-memory (or more importantly, my vimrc :)


i can't imagine why not -- it's the coolest new feature since
'cursorline'



I just want to comment that I also think it's the best new
feature (since folding, from my perspective..)

I wrote my own plugin that used sign column to show line
numbers relative to top line, but it was a pain in the
ass to have all mappings refresh the numbers when a line
is inserted or deleted or screen is moved.

If anyone's not using this, totally try it out!!!

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: how to make 'h,j,k,l' faster ?

2011-10-28 Thread AK

On 10/28/2011 02:43 PM, George V. Reilly wrote:


You know what'd really make a difference for relative line numbering?
If the current line's number was its absolute line number, instead of
0. Yes, I can see the absolute line number down in the ruler, but
that's often far removed from the current line and I have to move my
eyes down to the ruler, then back to the current line. 0 conveys
little information. The absolute line number is more useful. It should
be in a highlighted color to make it blatantly clear that it's
different.



I have to disagree, at least for me, absolute line number is not
something I need that often. Absolute line number would need an
extra column or two. I have relative line numbers column set to
3 - 2 digits and one column of padding (which looks like it's not
possible to remove?)

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Disabling ultra-annoying drag text with html markup from browsers

2011-10-23 Thread AK

On 10/23/2011 08:10 AM, Bram Moolenaar wrote:


Andrei Avk wrote:


Hi, I asked about this (Disabling drag text with html markup from
browsers) about a month ago and I finally got around to trying to find
a fix and was able to do this by recompiling Gvim with following lines
commented out:


static const GtkTargetEntry selection_targets[] =
  /* {text/html,0, TARGET_HTML},  */

static const GtkTargetEntry dnd_targets[] =
  /* {text/html,0, TARGET_HTML},  */

Hopefully if anyone else needs this they'll be able to find this
temporary fix.


Have you tried removing html from the 'clipboard' option?



I never had html in my 'clipboard' at all. I think 'clipboard'
does not affect drag-n-drop.




However, it seems like a completely pointless and annoying feature..
possibly it would be better to disable html drops by default and have it
available as an option?


This is a very useful feature if you are working on web pages.
I have used it to copy syntax-highlighted code, the output from 2html,
into a web page that is edited through a browser.



Fair enough, but I think a much more common case is when users drag
and drop text from browser, e.g. code samples or anything else, and
a typical webpage will have the text surrounded by a great amount
of unreadable markup that then has to be deleted.

(This is on linux, by the way).

 -ak


--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Disabling ultra-annoying drag text with html markup from browsers

2011-10-23 Thread AK

On 10/23/2011 03:10 PM, Bram Moolenaar wrote:


Andrei Avk wrote:


Hi, I asked about this (Disabling drag text with html markup from
browsers) about a month ago and I finally got around to trying to find
a fix and was able to do this by recompiling Gvim with following lines
commented out:


static const GtkTargetEntry selection_targets[] =
   /* {text/html,   0, TARGET_HTML},  */

static const GtkTargetEntry dnd_targets[] =
   /* {text/html,   0, TARGET_HTML},  */

Hopefully if anyone else needs this they'll be able to find this
temporary fix.


Have you tried removing html from the 'clipboard' option?


I never had html in my 'clipboard' at all. I think 'clipboard'
does not affect drag-n-drop.




However, it seems like a completely pointless and annoying feature..
possibly it would be better to disable html drops by default and have it
available as an option?


This is a very useful feature if you are working on web pages.
I have used it to copy syntax-highlighted code, the output from 2html,
into a web page that is edited through a browser.



Fair enough, but I think a much more common case is when users drag
and drop text from browser, e.g. code samples or anything else, and
a typical webpage will have the text surrounded by a great amount
of unreadable markup that then has to be deleted.

(This is on linux, by the way).


I don't see this.  Just a simple copy and paste only contains the text,
no HTML.

Ah, wait, with gvim and using drag  drop instead of copy  paste I can
see it.  I'm not sure why this happens, must have something to do with
how GTK deals with the drop.  In gui_gtk_set_dnd_targets() it does check
the HTML flag in 'clipboard'...  Ah, this should fix it:


*** ../vim-7.3.346/src/gui_gtk_x11.c2011-08-10 17:44:41.0 +0200
--- src/gui_gtk_x11.c   2011-10-23 20:56:38.0 +0200
***
*** 3081,3087 

   for (i = 0; i  (int)N_DND_TARGETS; ++i)
   {
!   if (!clip_html  selection_targets[i].info == TARGET_HTML)
n_targets--;
else
targets[j++] = dnd_targets[i];
--- 3081,3087 

   for (i = 0; i  (int)N_DND_TARGETS; ++i)
   {
!   if (!clip_html  dnd_targets[i].info == TARGET_HTML)
n_targets--;
else
targets[j++] = dnd_targets[i];





This does work! Thanks so much for your response and the fix,
and the truly great editor (I think vim is the most impressive
program I've used).

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Disabling ultra-annoying drag text with html markup from browsers

2011-10-22 Thread AK

Hi, I asked about this (Disabling drag text with html markup from
browsers) about a month ago and I finally got around to trying to find
a fix and was able to do this by recompiling Gvim with following lines
commented out:


static const GtkTargetEntry selection_targets[] =
/* {text/html,  0, TARGET_HTML},  */

static const GtkTargetEntry dnd_targets[] =
/* {text/html,  0, TARGET_HTML},  */

Hopefully if anyone else needs this they'll be able to find this
temporary fix.

However, it seems like a completely pointless and annoying feature..
possibly it would be better to disable html drops by default and have it
available as an option?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Disabling ultra-annoying drag text with html markup from browsers

2011-10-22 Thread AK

On 10/22/2011 05:00 PM, AK wrote:

Hi, I asked about this (Disabling drag text with html markup from
browsers) about a month ago and I finally got around to trying to find
a fix and was able to do this by recompiling Gvim with following lines
commented out:


static const GtkTargetEntry selection_targets[] =
/* {text/html, 0, TARGET_HTML}, */

static const GtkTargetEntry dnd_targets[] =
/* {text/html, 0, TARGET_HTML}, */

Hopefully if anyone else needs this they'll be able to find this
temporary fix.

However, it seems like a completely pointless and annoying feature..
possibly it would be better to disable html drops by default and have it
available as an option?

-ak


I forgot to add that the lines are in gui_gtk_x11.c file.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: How to conceal entire line including newline?

2011-10-07 Thread AK

On 10/06/2011 11:42 PM, sal migondis wrote:

Well, here's an example:

# comment
code
# comment
# second line
code
# comment
code

I want to have:

code
code
code

Folding cannot do that because it does not conceal, it only folds.



I never remove comments (or doc strings) when reviewing code, but I
occasionally have the same type problem with config files that come
with some programs (apache, squid, ELinks, etc.) where each coded
value has 10-15 lines of comments that serve as a kind of a
program.conf man page.

Some of these config files can run to thousands of lines with some 99%
being comments or sample values that are commented out.

Confusing.

So when I need a quick peek at the actual config all on one screen, I
simply do a:

:g/^#/d   or ..
:g/^/dor..
:g/^!/d
etc...

followed  of course by an undo or quit w/o saving.

Never had a problem with this approach, but if you're worried, you
could open the file readonly or set the readonly option after deleting
the comments (all in one pass if you map a little function that
deletes all different different comment syntax forms and sets the
readonly option to an Fxx key - e.g.)

Obviously not a solution if you're also modifying the code; but then
you may want to see the comments  doc strings.. just to make sure
they still match the new code!

Sal




I thought about creating a new scratch buffer with comments 
docstrings omitted. But I do need to modify the code, so that's
not going to work, either.

I'm not worried about comments getting out of sync with the
code, first of all because it happens all the time anyway and
I do a review of all comments at the end of a session and update
them all in one go.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


How to conceal entire line including newline?

2011-10-05 Thread AK

Hi, I want to have an overview of code without comments or
docstrings, with their lines completely omitted when in
conceal mode, without showing them as blank lines.

How can I do that?

Thanks,  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: How to conceal entire line including newline?

2011-10-05 Thread AK

On 10/05/2011 02:41 PM, Christian Brabandt wrote:

Hi AK!

On Mi, 05 Okt 2011, AK wrote:


Hi, I want to have an overview of code without comments or
docstrings, with their lines completely omitted when in
conceal mode, without showing them as blank lines.

How can I do that?


You can't. Use folding to hide them away.

regards,
Christian



Wow, why is conceal so bizarrely hindered? Even before
conceal feature was created, I've often thought that it
would be extremely useful to temporarily conceal some
types of lines.

That just seems completely inexplicable to me.

Folding, of course, does not hide lines, it just folds
them. And I do need to still have folding e.g. of methods
and classes while docstrings and comments are concealed.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: How to conceal entire line including newline?

2011-10-05 Thread AK

On 10/05/2011 03:36 PM, Christian Brabandt wrote:

Hi AK!

On Mi, 05 Okt 2011, AK wrote:


On 10/05/2011 02:41 PM, Christian Brabandt wrote:

On Mi, 05 Okt 2011, AK wrote:

Hi, I want to have an overview of code without comments or
docstrings, with their lines completely omitted when in
conceal mode, without showing them as blank lines.

How can I do that?


You can't. Use folding to hide them away.


Wow, why is conceal so bizarrely hindered? Even before
conceal feature was created, I've often thought that it
would be extremely useful to temporarily conceal some
types of lines.


Well you can hide away lines, but I think you won't be able to
completely hide away the new line character. This makes sense, as for
this folding can be used.



Well, here's an example:

# comment
code
# comment
# second line
code
# comment
code

I want to have:

code
code
code

Folding cannot do that because it does not conceal, it only folds.


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php



Re: How to conceal entire line including newline?

2011-10-05 Thread AK

On 10/05/2011 04:11 PM, Christian Brabandt wrote:

Hi AK!

On Mi, 05 Okt 2011, AK wrote:


On 10/05/2011 03:36 PM, Christian Brabandt wrote:

Hi AK!

On Mi, 05 Okt 2011, AK wrote:


On 10/05/2011 02:41 PM, Christian Brabandt wrote:

On Mi, 05 Okt 2011, AK wrote:

Hi, I want to have an overview of code without comments or
docstrings, with their lines completely omitted when in
conceal mode, without showing them as blank lines.

How can I do that?


You can't. Use folding to hide them away.


Wow, why is conceal so bizarrely hindered? Even before
conceal feature was created, I've often thought that it
would be extremely useful to temporarily conceal some
types of lines.


Well you can hide away lines, but I think you won't be able to
completely hide away the new line character. This makes sense, as for
this folding can be used.



Well, here's an example:

# comment
code
# comment
# second line
code
# comment
code

I want to have:

code
code
code

Folding cannot do that because it does not conceal, it only folds.


Close enough:
:setl foldenable foldmethod=expr foldminlines=0
foldexpr=getline(v:lnum)=~'^#'?1:0 foldtext=v:folddashes foldlevel=0
fillchars-=fold:-

which makes it:
-
code
-
code
-
code


Well, I already did use 'invisible' folds to do
similar type of hiding, but I was really excited
about conceal feature because I thought it would
be able to conceal lines.

The reason I want to get rid of those lines is that
you can read a lot more code in the same window
and it makes it much, much easier to do code review
without jumping back and forth.

So, it's really odd to me that conceal does not work
for lines. It seems like the most useful part of
conceal is handicapped by design.

Is it possible to make a small change to the vim
code to allow this? I would not mind compiling my
own version of Vim to allow this even though the
patch will need to be applied on every upgrade.

I don't have experience with C or editing Vim code
so it would be really helpful if someone told me
if it would be easy to add and where I should start.

I would be willing to spend a few hours on this,
but if it's going to be harder than that, I'll just
use folding and syntax highlight to make folds
invisible.

Thanks for your help, Christian.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: How to conceal entire line including newline?

2011-10-05 Thread AK

On 10/05/2011 05:37 PM, Christian Brabandt wrote:

Hi AK!

On Mi, 05 Okt 2011, AK wrote:

I would be willing to spend a few hours on this,
but if it's going to be harder than that, I'll just
use folding and syntax highlight to make folds
invisible.


I think this is harder then it sounds, because concealing is hard to get
right, has some nasty corner cases and the concealing code still has
some bugs (see :h todo.txt). So I don't think this is likely to change
anytime soon.

regards,
Christian




Ok, thank you.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Dealing with virtual indent inside a function

2011-10-02 Thread AK

I have an insert mapping for tab key that works right for existing
lines, but does not work right for a new line with 'virtual' indent
level.

Normally, if it's in a mapping, it can be fixed by adding any key and
then backspace to erase it. I'm trying to do the same inside of a
function, and nothing I've tried works for me.

fun! TriggerSnippet()
if getline('.') =~ '^\s*$'
call feedkeys(x, 't')
:redraw
call feedkeys(\bs\tab, 'n') | return ''

...
endfu

This is at the top of snipmate's TriggerSnippet, by the way. I think
snipmate has some way of dealing with this but I don't know where it is
or how it works, so if someone can point this out, that might help.
Because I have another function that closes popup menu before triggering
snippet when tab key is pressed, snipmate's workaround for this does not
work.

Any help appreciated!

-ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Insert a tab or call a function

2011-09-29 Thread AK

On 09/29/2011 08:15 AM, Christian Brabandt wrote:

On Thu, September 29, 2011 1:52 pm, AK wrote:

On 09/29/2011 01:58 AM, Benjamin R. Haskell wrote:

On Wed, 28 Sep 2011, AK wrote:

Hi, I'm trying to write a small function that is called when I press
tab key and checks if current line is empty; if it is, it should
insert a tab, and if not, it should call two other functions. Here's
the example of what I came up with, which does not work right:


Wanting to either insert something or run another function is a good
case forexpr  mappings. It depends a bit on how TriggerSnippet works,
the following might be all you need:

fun! DoTab()
if getline('.') =~ '^\s*$'
return \tab
else
call CloseMenu()
return TriggerSnippet()
endif
endfun
inoexpr  tab  DoTab()


I get 'E523: not allowed here' in TriggerSnippet. I tried :set secure ,
but that did not help.


I think what happens is, that one of your functions triggers an
action, that is not allowed inside an expr-mapping. If you need to do
something like this, you need to have the functions return the
commands, that will do that.

See :h :map-expr
and look at the third paragraph.



I would like to avoid changing trigger snippet function because it's
complicated and to be able to upgrade it later. The issue is,
I want to call the function using a mapping to c-o:call myfunc()cr
and then I want it to do the check, and to insert a literal tab without
any side effects if current line is empty; if line is not empty, I need
it to run CloseMenu and then trigger snippet.

When this line runs:

call feedkeys(\tab, 'n') | return ''

TriggerSnippet is triggered.. and I don't understand why that happens, I
thought this should input a literal tab?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Insert a tab or call a function

2011-09-29 Thread AK

On 09/29/2011 08:15 AM, Christian Brabandt wrote:

On Thu, September 29, 2011 1:52 pm, AK wrote:

On 09/29/2011 01:58 AM, Benjamin R. Haskell wrote:

On Wed, 28 Sep 2011, AK wrote:

Hi, I'm trying to write a small function that is called when I press
tab key and checks if current line is empty; if it is, it should
insert a tab, and if not, it should call two other functions. Here's
the example of what I came up with, which does not work right:


Wanting to either insert something or run another function is a good
case forexpr  mappings. It depends a bit on how TriggerSnippet works,
the following might be all you need:

fun! DoTab()
if getline('.') =~ '^\s*$'
return \tab
else
call CloseMenu()
return TriggerSnippet()
endif
endfun
inoexpr  tab  DoTab()


I get 'E523: not allowed here' in TriggerSnippet. I tried :set secure ,
but that did not help.


I think what happens is, that one of your functions triggers an
action, that is not allowed inside an expr-mapping. If you need to do
something like this, you need to have the functions return the
commands, that will do that.

See :h :map-expr
and look at the third paragraph.

regards,
Christian




Ok, I think I'm getting there: I've added the check to the
top of TriggerSnippet:

if getline('.') =~ '^\s*$'
 return \tab
call feedkeys(\tab, 'n') | return ''
endif

Now the issue is only that when I go to a new line by pressing
enter, first tab I press is 'eaten'. Nothing happens at all.
Subsequent tabs work fine. If I press 'a' key at the end of
an existing empty line, tab also works fine, i.e. the first
tab does not get 'eaten'.

The same behaviour occurs if I uncomment the 2nd line in
code I pasted.

If I understand right, when a new line is created, it's indent
is 'virtual', and that seems to cause this problem. I still
don't understand why, though, since tab should not be affected
by indent being virtual or not.. I may be completely off track
here..

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Insert a tab or call a function

2011-09-28 Thread AK

Hi, I'm trying to write a small function that is called when I press tab
key and checks if current line is empty; if it is, it should insert a
tab, and if not, it should call two other functions. Here's the example
of what I came up with, which does not work right:

function! DoTab()
if match(getline('.'), '^\s*$') != -1
call feedkeys(\tab) | return ''
else
call CloseMenu()
call feedkeys(\c-r=TriggerSnippet()\cr) | return ''
endif
endfu
ino silent tab c-o:call DoTab()CR

CloseMenu is another function I have that closes a popup menu if it's
open, TriggerSnippet is a snipmate function that expands current
snippet.


Thanks!  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Lines displayed in wrong order on 'Load'

2011-09-25 Thread AK

On 09/25/2011 07:59 AM, Bram Moolenaar wrote:


Andrie Avk wrote:


I'm running into a weird issue with vim 7.3 1-35 on Ubuntu.

When a file is modified outside of vim in a way that adds a single line
(it's always added in a third line from top, but I don't think that
matters), and when you switch to the buffer, Vim prompts to load the
file. If I choose to load, the line is displayed as being 4th line from
top. If another line is added as third line again, it's now displayed as
5th line, and so on.

If I type :edit , lines will show in proper order.

For my needs this is not a big issue at all, but I was wondering if this
is a known issue, is it fixed in latest vim, should I submit a bug
report?


I can't imagine how this can happen.  Perhaps a plugin causes problems?
Did you try starting with vim -u NONE?




Here's some more detail on what I was doing:

I wrote a python vim function that accepts a line from user input, reads
all lines from a file that's currently loaded in another vim buffer, and
writes the file out again, inserting the new line as 3rd line of the
file.

Initially I wrote it as:

lines = open(fname).readlines()
lines.insert(2, newline+'\n')
with open(fname, 'w') as fp: fp.writelines(lines)

I made a small mistake when describing the issue in my first report, in
fact the first line is added in the correct position, but when I was
adding a 2nd line, it was showing up one line down from where it should
be, 3rd line would be one line lower still, and so on.

I thought that the issue may be that I'm not closing the file explicitly
after reading, so I changed the reading to use the same 'with open ...'
form.

The issue was still present and then I added debugging prints to show
that new lines are in the right position in `lines`, and they were.

Because of :edit of that file showing lines in correct order, I thought
it's a vim problem and not anything to do with the python function.

After a vim restart, however, everything works fine even from the python
function. I don't think this was caused by any plugin because right now
I have all the same plugins loaded.

I'm also not sure why a restart fixed it. I should have tried it before
sending the email.

Thanks,

 - ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Lines displayed in wrong order on 'Load'

2011-09-24 Thread AK


I'm running into a weird issue with vim 7.3 1-35 on Ubuntu.

When a file is modified outside of vim in a way that adds a single line
(it's always added in a third line from top, but I don't think that
matters), and when you switch to the buffer, Vim prompts to load the
file. If I choose to load, the line is displayed as being 4th line from
top. If another line is added as third line again, it's now displayed as
5th line, and so on.

If I type :edit , lines will show in proper order.

For my needs this is not a big issue at all, but I was wondering if this
is a known issue, is it fixed in latest vim, should I submit a bug
report?

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Complete text object?

2011-09-22 Thread AK

On 09/22/2011 10:37 AM, Ben Fritz wrote:



On Sep 21, 6:44 pm, AKandrei@gmail.com  wrote:

Is there a plugin to complete a text object?

e.g. where | is cursor:

one two three fourc-xc-z

one two three four three four

one two three four oc-xc-z

one two three four one two

And the same thing for other text objects, of course?

What other neat things might be done with text objects, in theory (I'm
thinking of ideas for a new plugin)?



It looks like you're trying to complete strings. I don't know of a
plugin to do that, but your subject is more interesting to me than
your example, because Vim supports a variety of text-objects



Of course, I didn't want to give examples for all text objects, I
hoped it's enough to give one example. I was mostly thinking about
',  strings and xml tags, because sentences and paragraphs would
be harder to disambiguate... maybe code blocks too, but I mostly
use python and python functions are not official text-objects
anyway.


(see :help text-objects) such as sentences, paragraphs, code blocks,
xml-style tags, words, WORDs, strings with , strings with ', and
more. I think it would be really neat to be able to complete any of
these...but probably fairly difficult to accomplish, especially with
an acceptable level of performance. Maybe if it were limited to a very
small number of buffers (current buffer only? visible buffers only?).



I was definitely thinking of current buffer only, and maybe even limited
to some small number of preceding / following text objects. Like 5 or 
10. That'd be enough to be very useful.


  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Complete text object?

2011-09-21 Thread AK

Is there a plugin to complete a text object?

e.g. where | is cursor:

one two three four c-xc-z

one two three four three four

one two three four oc-xc-z

one two three four one two

And the same thing for other text objects, of course?

What other neat things might be done with text objects, in theory (I'm
thinking of ideas for a new plugin)?

Thanks! -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Repeat last search and replace

2011-09-14 Thread AK

On 09/14/2011 09:45 AM, Russell Bateman wrote:

Once I've typed in a command to search and replace for something, for
example:

%s/search/replace/g

how can I re-execute that command without retyping it? (I have a string
of source files between which I'm moving via :n each time and I don't
want to have to retype the command; dot won't work obviously.)

Thanks,

Russ




Use @: command, see :help @:

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Repeat last search and replace

2011-09-14 Thread AK

On 09/14/2011 09:45 AM, Russell Bateman wrote:

Once I've typed in a command to search and replace for something, for
example:

%s/search/replace/g

how can I re-execute that command without retyping it? (I have a string
of source files between which I'm moving via :n each time and I don't
want to have to retype the command; dot won't work obviously.)

Thanks,

Russ




Oh, and after doing @: once, you can repeat it easier with @@  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: gvim or vim in console...

2011-09-12 Thread AK

On 09/12/2011 10:58 AM, Ben Fritz wrote:


I don't have much reason behind my choice, I just like it better. I'm
not fond of being bound to a terminal window, I use it when I need to
but usually separate from Vim. I do know that the terminal version
causes all sorts of headaches; as evidenced by the mailing list, wiki,
and IRC channel. More key mappings are normally available in gvim, you
don't need to worry about how many colors your term has or how it
renders combinations of ctermfg and cterm, color schemes are usually
written for gvim, you can set the font quickly and easily, etc. As for
interacting with other tools which need to know when the editor is
done, there's the -f argument when launching Vim.



I want to add that I also use Gvim 95+% of time for all the same
reasons. I almost always use it on linux. I never use vim tabs,
I should probably try them for a few weeks.



I'm also not fond of needing to suspend Vim with Ctrl-Z and bring it
back up whenever I want to do work with the terminal. I like having
them side-by-side. I could launch two terminal windows or start
looking into screen (I think anyway, never tried it), or I could
just launch the GUI and be done with it.



+1 except that I sometimes use vim with ctrl-z when using remote ssh
session.

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: question about foldmethod=indent

2011-09-10 Thread AK

On 09/10/2011 05:53 PM, Gelonida N wrote:

Hi,


I have a small question.

for some text_file  I wanted to use foldmethod=ident


I have following
buffer ( no tabs / only blanks)


000
000
000
 11
 
 111
 2
 2
 2
 2
 2



All the lines containing '2' can be folded and unfolded

however vim does not fold the  first level so the lines with '1'
characters are not  being folded.


Is there any parameter, such, that I can fold already the very first
indentation.

I was convinced, that the last time, that I used vim with
foldmethod=indent, I was able to fold the first level, but probably I
just remember wrong.


Thanks in advance for your help




It has to be 4, not 5 spaces, I think then it will indent.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: reading a singly character from a python script for vim

2011-09-10 Thread AK

On 09/10/2011 02:04 PM, Gelonida N wrote:

Hi,


Concerning vim scripting I'm an absolute beginner, so forgive my if
the answer to my question is obvious


J just started looking at what would be possible from within a
vim-python script.


If I want to get text input from the user (with a prompt) I found
following recipe.

def readline(prompt):
 vim.command('call inputsave()')
 vim.command('let user_input = input(%s)' % prompt)
 vim.command('call inputrestore()')
 return vim.eval('user_input')



Now I wondered whether there is a way, that python could capture a
single key press without any prompt.


Thanks in advance for suggestions.








I think you can do something like:

from vim import *
c = eval(getchar())

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: reading a singly character from a python script for vim

2011-09-10 Thread AK

On 09/10/2011 09:27 PM, Gelonida N wrote:

Hi AK,

Thanks a lot.

Yes exactly what I was looking for.

Now I can dstart a python script from vim and react on a few key presses




No problem, glad it works for you.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: The X bug with Gvim

2011-09-07 Thread AK

On 09/07/2011 07:31 PM, Jacky Liu wrote:



On Sep 6, 1:40 am, Jacky Liubluegene8...@gmail.com  wrote:

Hi everyone

I need multi-threading in Vim because I need some work being done
under the desk without turning Vim into a zombie, now I know Vim is
single-threaded, so I decided to give Python a try, demonstration:

  x-bug.vim

 python3  EOF

 import threading
 import time

 print('thread 1')

 def print_to_vim():
 print('thread 2')

 threading.Thread(name='test', target=print_to_vim).start()

 print('thread 1 again')

 time.sleep(3)

 EOF

The above code works fine with console Vim as it prints the intended
message while everything else look normal, but it would make Gvim
collapse every time it's been sourced, leaving this message:

 gvim: Fatal IO error 11 (Resource temporarily unavailable) on X
server :0.0.

The problem seems to be with the X system. I did some more test and it
seems ok to have multiple Python threads in Gvim, but only one of
these threads is permitted to interact with the GUI (means to cause
any change of display within the Gvim program window)

Since I'm an ordinary user to both Vim and Python and don't know much
about the Unix System, can anyone please tell me:

1. Should this be considered a bug?

2. Is there any way to get around this, thus making it safe to have
several Python threads interacting with Gvim?

Thanks



Please, isn't there anyone interested in this topic?

I think doing multi-threading in Vim would find great use, like in
Conque -- its current implementation is far from optimal. Follow this
way down we may use Vim as an excellent UI for almost any text-based
program there is (or going even further with non-text based programs
if you like), and now this X-bug or whatsoever seems to be the biggest
(if not last) obstacle.

Anyone? Please tell me what you think.

Besides, the vim doc had nothing on this topic, it didn't say that
Python shouldn't go multi-threaded with Gvim. Should I try to post
this in the vim_dev group?




I agree that better integration with Python, including multithreading,
would be the best new feature for Vim. I think the issue is that
it's not easy to do? At least, it ranks #2 in this list:

http://www.vim.org/sponsor/vote_results.php

And so far I don't think much was done in this respect, so here's
hoping for the future...

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: repeat command line

2011-09-05 Thread AK

On 09/05/2011 05:01 AM, Joachim Hofmann wrote:

Hello,

@:
repeats the last command line.
How can I additionally automatically search for the last command which
begings with ! for being executed?

Thank You
Joachim



:!! will run the last :! command. :h :!!

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: repeat command line

2011-09-05 Thread AK

On 09/05/2011 08:19 AM, Joachim Hofmann wrote:



:!! will run the last :! command. :h :!!


Thank You. The solution to search in the history is less dangerous
though, because I can give a part of the desired/expected execution string.

Joachim




Yes, it's useful mainly when you're developing and running a script over
and over. I even have an alt-key shortcut for it.  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Problem with text drag-and-drop from browser to gvim

2011-09-04 Thread AK

Hi,

I often need to copy and paste snippets of text from webpages into gvim.
The easiest way to do this is to highlight and drag and drop text.
Unfortunately, gnome helpfully adds all kinds of tags
around the text (when using chrome; adds ^@ chars with Firefox). Other
programs like gedit, abiword, terminal only get the text dropped without
tags.

How can I get plain text in Gvim?

I know that I can set up a mapping to strip tags, but I hope there's a
way to do this automatically.

I googled for this issue with no luck.

Thanks!  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Problem with text drag-and-drop from browser to gvim

2011-09-04 Thread AK

On 09/04/2011 12:40 PM, Marty Fried wrote:

On Sun, Sep 4, 2011 at 8:40 AM, AK andrei@gmail.com
mailto:andrei@gmail.com wrote:

Hi,

I often need to copy and paste snippets of text from webpages into gvim.
The easiest way to do this is to highlight and drag and drop text.
Unfortunately, gnome helpfully adds all kinds of tags
around the text (when using chrome; adds ^@ chars with Firefox). Other
programs like gedit, abiword, terminal only get the text dropped without
tags.

How can I get plain text in Gvim?

I know that I can set up a mapping to strip tags, but I hope there's a
way to do this automatically.

Personally I find it easier to cut and paste rather than drag and drop.
  That doesn't require that both windows be visible at the same time,
and I feel I have more control over where it goes.  Seems more like the
vim way, too.



I find it much easier to drag and drop in this instance, because in 
99.9% of cases both of my windows are visible, because I do coding

with browser open to the side of gvim, and I start insert mode
at the right spot beforehand.


I think the issue is that Gvim sets itself up as a DnD text target
that accepts formatting. There doesn't seem to be a way to tweak
this outside of vim code.

Does anyone know what code I need to change in Gvim itself? Or is
there an easier way?


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: :e handles one file

2011-08-22 Thread AK

On 08/22/2011 01:47 PM, Tim Chase wrote:

On 08/22/2011 12:09 PM, Tom wrote:

I know :args can load multiple files in multiple buffers but why would
you explicitly make :e only handle one, then complain if there's more
then one argument and create other commands to do what you're trying
to prevent with the first command? That seems a bit illogical...

Would it be a good idea to have vim handle multiple files with :e in
the future, and if not why?


Because :e replaces the contents of the current window with the contents
of the specified file, asking for multiple files makes for an undefined
result: should the first file be put in the current window, and the
other files added to the args? Should the first file be put in the
current window, and the other files split into other windows? How about
each in its own tab?




Should the last file in the resulting filespec
override the others (as if :e f[12].txt did the same thing as :e
f1.txt followed by :e f2.txt)?



My guess is that if you asked 100 vim users, 90-95 would be fine with
either leaving first or last file in current window and loading the
rest in buffer list.

I have to say this is an odd argument.. Vim has maybe on the order of
five thousand commands and options that might conceivably work one way
or another, one way is chosen as a more reasonable default and the
other ways are available via a setting or some workaround.

But for this command, out of thousands, it can't be done!

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-22 Thread AK

On 08/22/2011 01:58 PM, ZyX wrote:

Reply to message «Re: Tweaking $ command»,
sent 22:17:27 21 August 2011, Sunday
by AK:


The 'k' was fixing downward movement of $ command. After replacing with
normal! $, it works without that fix.

`$' does not move downward on its own. I don't see why it should move downward
(unless you kill that condition: in this case it will move because 0-1==-1 and
`-' moves, but upward).



It does move downward. 3$ moves 2 lines downward, etc.




2. :h map-expr:
  nnoremap $ Bar$.((v:count1)?(((v:count-1).'h'):(''))


That doesn't work for me, using vim 7.3 (even after adding the ')').
However, I prefer the function version because it's more readable.

Oops, I forgot to pull fixes to the message after testing:
 nnoremapexpr  $ Bar$.((v:count1)?((v:count-1).'h'):(''))



Thanks, that works and good to know. I think I still prefer function
version for readability.




I see, butc-u  seems like a pretty bad kludge. I remember using it at
least a couple of times before, and I still did not remember it because
it's pretty counter-intuitive. I think it would be better if there was
an arg to *map to turn it off, likeno-prepend-range, because users
would look into *map arguments help for explanation of this behaviour.

It is not related to :*map at all, it is property of `:'. By the way, you saw
`Bar' above? It is for the same job here: drop count. Another possibility is
C-\C-n: in this case {count} is ignored.



Ok, I see.. but why does map or function have to do anything with that,
they already get v:count and v:linenumber1 etc (IIRC), why isn't it up
to them to choose how to use or not use them?




Because v:count is reset each time normal-mode command is executed. Guess
why in

 exe normal \End

command is called *normal*?


That doesn't seem reasonable, why should Vim assume the count applies to
the first (of possibly dozens) normal command in a function?

I don't said it is *applied*. I said it is *reset* when normal-mode command is
executed. `normal' does execute the normal-mode command as clearly stated by its
name.



Either reset or applied, I don't see the logic in having that happen
with the first normal command in a function.




Anyway, thanks a ton for your help and here's what I ended up with if
anyone wants to use this too:

func! EndOfLine()
   Go to Nth char before end of line
  normal! $
  if v:count | exe normal .v:count.h | endif
endfu
nnoremap $ :c-ucall EndOfLine()cr

This won't work for {count}$, see above.


?? It does work for me in Vim 7.3. For both $ and {count}$ .


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-22 Thread AK

On 08/22/2011 02:56 PM, ZyX wrote:

Reply to message «Re: Tweaking $ command»,
sent 22:26:44 22 August 2011, Monday
by AK:


It does move downward. 3$ moves 2 lines downward, etc.

Now see this in help. For some reason it was not working before while testing
(perhaps forgot to add more lines).


Ok, I see.. but why does map or function have to do anything with that,
they already get v:count and v:linenumber1 etc (IIRC), why isn't it up
to them to choose how to use or not use them?

You choose: byC-u. I don't like it either: it cost me much time trying to get
rid of this inexpr  mapping for visual mode.



I think it's also a particularly bad kludge because it's hard for a user 
to know what to look for in help system.





I don't said it is *applied*. I said it is *reset* when normal-mode
command is executed. `normal' does execute the normal-mode command as
clearly stated by its name.


Either reset or applied, I don't see the logic in having that happen
with the first normal command in a function.

I don't rememeber it applied anywhere (though I don't like :normal! very much so
I can't say I tested this on all commands). On my setup it is simply ignored and
reset.


This won't work for {count}$, see above.


?? It does work for me in Vim 7.3. For both $ and {count}$ .

vim-7.3.266 (~amd64) USE=X acl bash-completion cscope gpm nls perl python ruby
   vim-pager -debug -minimal, Gentoo

With the following script

 vim -u NONE -N \
 --cmd 'exe fu_()\nnorm!$\nif v:count|exe\norm\.v:count.\h\|en\nendf' 
\
 --cmd 'nnoremap $ :C-ucall _()CR' \
 --cmd 'call setline(., range(10, 100500))'



Yes, it works fine for me in 7.3 with patches 1-35, 3$, 2$, etc. I 
haven't seen the reason to update so far, is there a list of new stuff 
in vim dev version? I don't know if I should update just to break my 
function :-).  -ak


--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-22 Thread AK

On 08/22/2011 04:01 PM, ZyX wrote:

Reply to message «Re: Tweaking $ command»,
sent 23:08:55 22 August 2011, Monday
by AK:


I think it's also a particularly bad kludge because it's hard for a user
to know what to look for in help system.

If I am not mistaking, I found this just as you: from someboby's code.


Yes, it works fine for me in 7.3 with patches 1-35, 3$, 2$, etc. I
haven't seen the reason to update so far, is there a list of new stuff
in vim dev version? I don't know if I should update just to break my
function :-).  -ak

List is in :h version-7.3 in vim-7.3. There is an online version of help
somewhere (or you can use googlecode code browser). I like the following:
1. persistent undo
2. strdisplaywidth()
3. extra argument to maparg() (useful to script writers only)
3. changes to `tC;' behavior



Thanks! None of this seems particularly useful for my needs, I'll
stay with older version for now..

 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-22 Thread AK

On 08/22/2011 05:21 PM, Tim Chase wrote:

I got it working with:

:nnoremapsilent  $ :c-uexec 'norm
'.((virtcol('$')-v:count)0?0:(virtcol('$')-v:count)).'bar'cr


Thanks, but that doesn't work right for me without the count (vim 7.3).
I think the function version is preferable for readability, as well.  -ak


I'm not sure what you mean about it not working right without the
count.  Without the count, it just acts like $ normally does (with the
small exception that Vim remembers that it's in column-X instead of
at-the-EOL, so subsequent vertical movements such as j/k stay in the
same column instead of jumping raggedly to the EOL on each line).

-tim



When I pasted into vim, somehow a single trailing space got added and it
made '$' command go one line down, for some reason I don't understand.
After fixing, it does work fine.

  -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-21 Thread AK

On 08/20/2011 07:57 PM, ZyX wrote:

Reply to message «Tweaking $ command»,
sent 03:05:13 21 August 2011, Sunday
by AK:


Is there a better way to do this?

0. You said you want just
  to change $ command to go to N chars before the end of line
but what in this case `k' is doing in the second :normal command?



The 'k' was fixing downward movement of $ command. After replacing with 
normal! $, it works without that fix.



1. You must not use :normal here (you could replace
exe normal \End
with
normal! $
): use :normal! (with bang).
2. :h map-expr:
 nnoremap $ Bar$.((v:count1)?(((v:count-1).'h'):(''))



That doesn't work for me, using vim 7.3 (even after adding the ')'). 
However, I prefer the function version because it's more readable.





Why isc-u  needed there?

Try typing `2:', then read a paragraph before :h function-range-example (second
paragraph in :h :call).



I see, but c-u seems like a pretty bad kludge. I remember using it at
least a couple of times before, and I still did not remember it because
it's pretty counter-intuitive. I think it would be better if there was
an arg to *map to turn it off, like no-prepend-range, because users
would look into *map arguments help for explanation of this behaviour.




If I
remapped $, why does it keep trying to do built-in $ handling of count?

Because v:count is reset each time normal-mode command is executed. Guess why in
   exe normal \End
command is called *normal*?



That doesn't seem reasonable, why should Vim assume the count applies to
the first (of possibly dozens) normal command in a function?

Is this sort of questions ok to bring up on vim-use list?

Anyway, thanks a ton for your help and here's what I ended up with if
anyone wants to use this too:

func! EndOfLine()
 Go to Nth char before end of line
normal! $
if v:count | exe normal .v:count.h | endif
endfu
nnoremap $ :c-ucall EndOfLine()cr


 -ak

--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Tweaking $ command

2011-08-21 Thread AK

On 08/20/2011 08:03 PM, Tim Chase wrote:

On 08/20/2011 06:05 PM, AK wrote:

Hi, I was trying to change $ command to go to N chars before the end of
line, and found it surprisingly hard to do. Here's what I come up with:

func! EndOfLine()
exe normal \End
let c = v:count
let c2 = c - 1
let cmd = normal  . c2 . k . c . h
if c | exe cmd | endif
endfu
nnoremap $ :c-ucall EndOfLine()cr


Is there a better way to do this?


I got it working with:

:nnoremap silent $ :c-uexec 'norm
'.((virtcol('$')-v:count)0?0:(virtcol('$')-v:count)).'bar'cr




Thanks, but that doesn't work right for me without the count (vim 7.3). 
I think the function version is preferable for readability, as well.  -ak


--
You received this message from the vim_use maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


  1   2   3   >