Re: Conditional imap

2010-06-29 Thread gitterrost4

I did what you told me to (i dont want to use (Tab but just ( to remap
to \left(). When I enter the command while i opended the Document
everything works fine. But when I put the command in my .vimrc (or the
tex.vim respectively) it stops working.

The map is present, it just won't replace the (.

Any Idea?


Christian Brabandt-3 wrote:
 
 On Mon, June 28, 2010 11:46 am, gitterrost4 wrote:
   I am using vim mostly for LaTeX-editing. now I would like to imap the
 sequence (Tab to \left(.

   The Problem being that \left( is only valid in Math-Mode.

   So I would like to first check (by regex) if I am in a Math-environment
 (e.g count the number of $-signs) and if so, imap the above mentioned.

   Is there any way of doing that?
 
 You can use map-expressions, as explained in :h map-expression
 
 Excuse my LaTeX skills, I haven't used math-mode in a while, but something
 like this should work:
 
 imap expr Tab synIDattr(synID(line('.'), col('.'), 1), name)=~
 texMath ? \left( : \t
 
 (one line)
 
 This obviously requires a working Syntax highlighting (e.g. :syntax on)
 and I am not sure, if the name texMath matches all different TeX Math
 environments.
 
 regards,
 Christian
 
 -- 
 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
 
 

-- 
View this message in context: 
http://old.nabble.com/Conditional-imap-tp29008528p29020858.html
Sent from the Vim - General mailing list archive at Nabble.com.

-- 
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: au BufReadPost * if readonly | set nomodifiable

2010-06-29 Thread Tony Mechelynck

On 06/05/10 22:26, Ben Fritz wrote:



On May 6, 1:22 pm, rudy_brudyke...@yahoo.com  wrote:

Hey guys thanks for your replies.
Still Doesn't work.
My gvim version is 7.2.
Aince at work I am using a revision control too, that is why having this
thing fixed is very helpful for me.
I almost shrunk my .vimrc down to this:


:set nocp
:set ru

   au BufReadPost * ifreadonly | set nomodifiable | endif
   autocmd BufRead,BufWinEnter * ifft!='qf' | letl:modifiable =
(readonly ? 0 : 1) | endif
---
And I used the last two lines interchangably.
But still not good.

But, I figured something intresting.
I think what is going on (at least from my observation) is that this
specific setting is buffer related setting and not a file related. I tried
using split function with the name of the second file next to it:
:split read_only_file.txt
and this worked.
BUT, if I do
:split .
(which is what I usually do) that opens up the directory, where I can select
my file, then it is hosed up.



Wow, HEY! I also see the autocmd not working, if I open the file from
the netrw directory exploration window. In fact, the readonly option
does not even get set!

If I then use :e in the new buffer (with no arguments) to reload the
buffer, the readonly and modifiable options get set as desired.

I tried with the .vimrc you sent. I did not try disabling all plugins
besides netrw, but I don't use very many of them.

The autocmd works fine using splits with your .vimrc and no plugins at
all. This means the directory listing won't work.


Then I thought that okay at least I know if I put the name of the file next
to that split command, then it will work.
BUT, another wired thing is that if I do the same thing on a writable file:
:split writable_file.txt
and when I try to modify it, it DOENS'T work. meaning that I cannot write
into that file.



This, I cannot reproduce.

I opened writeable_file, modifiable was set.
I :sp nonwriteable_file, nomodifiable was set.
I :sp writeable_file2, modifiable was set.

This works even when the writeable files do not exist for me.

All this was done with no plugins, and the .vimrc you supplied at the
top of this post.


conclusion:
this is what is going on:

If I use (e: new_file) or (split: new_file) or (vsplit: new_file), then:
Regardless of the writability/readability privileges, I CANNOT modify the
file. In other words, nonmodifiable is set.


Did you make sure to close down Vim, and launch a NEW vim, with the
new autocmd between loads?



If I use (e: .) or (split: .) or (vsplit: .), then:
I can select my other file, but again, regardless of the
writability/readability privileges, I CAN modify the files. In other words,
modifiable is set.



I can duplicate this. In addition, noreadonly is set regardless of the
file properties.


I am using Vim 7.2.411 on Windows XP.

My netrw plugin starts with:

 netrwPlugin.vim: Handles file transfer and remote directory listing
across a network
PLUGIN SECTION
 Date:Aug 10, 2008
 Maintainer:  Charles E Campbell, Jrndroc...@scampbellpfamily.abizm-
NOSPAM
 GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim


As a workaround, immediately after loading a file from NetRW, do an :e
with no arguments to reload the file and set the appropriate readonly/
modifiable options based on file attributes. I do not know why this is
not currently working.



Hm. Just a wild thought (untested): try the following (which assumes 
'nocompatible'):



  if has('autocmd')
au VimEnter * augroup nomodif
au VimEnter * au BufReadPost,BufNewFile * if buftype == 
\ | let l:ma = l:ro | endif
au VimEnter * augroup END
  endif


Then restart Vim (every time you make changes to your vimrc, and after 
saving your changes) in order to test it.


If it doesn't work: while editing a file where 'modifiable' is not what 
you expect:


:verbose setlocal ma? ro? bt?


Best regards,
Tony.
--
A disciple of another sect once came to Drescher as he was
eating his morning meal.  I would like to give you this personality
test, said the outsider, because I want you to be happy.
Drescher took the paper that was offered him and put it into
the toaster -- I wish the toaster to be happy too.

--
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: Conditional imap

2010-06-29 Thread Christian Brabandt
On Tue, June 29, 2010 9:22 am, gitterrost4 wrote:
 I did what you told me to (i dont want to use (Tab but just ( to
 remap
 to \left(). When I enter the command while i opended the Document
 everything works fine. But when I put the command in my .vimrc (or the
 tex.vim respectively) it stops working.

So when you enter a ( in insert mode, vim enters the ( or what are
you expecting? The mapping might not be active or vim doen't recognize
the math-mode.

Please show us the output of:
:verbose imap (
You can do this, by issuing:
:redir @+
:verbose imap (
:redir end
and pasting your clipboard into your mail. If this doesn't output the
mapping that was given, it might be, that some plugin (maybe Latexsuite
?) overrides your mapping.

If you want that mapping only for latex documents, I suggest, that you
put it into a filetype specific file. Create a file
~/.vim/ftplugin/tex.vim (This is for Unix, create Directories that don't
exist yet, for Windows, you can use $HOME/vimfiles/ftplugin/tex.vim) and
in that file you write your mapping. Note, that you probably want to
change the map to be buffer-local, so that in only applies to TeX-files.

To do that change the map to something like this:
imap ( expr buffer …

If you want to make sure, that no plugin overrides the mapping, you
could place the file tex.vim also below ~/.vim/after/ftplugin/ for Unix
and $HOME/vimfiles/after/ftplugin/ for Windows. That way, it will be
applied last overriding any setting that might have been applied by a
global or filetype plugin.

It might also be, that the math-mode is not correctly
recognized. To find out, what the name of the syntax highlighing for the
math mode is, put the cursor on the math-mode and issue:
:echo synIDattr(synID(line('.'),col('.'),1), name)

This should output something like texMathSomething. In case it is
something different, you need to adjust your mapping.

Oh and please don't top post. It is general list consensus to trim
quotes and reply inline.

regards,
Christian

-- 
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: Conditional imap

2010-06-29 Thread Christian Brabandt
On Tue, June 29, 2010 12:01 pm, Christian Brabandt wrote:
 To do that change the map to something like this:
 imap ( expr buffer …

This should obviously be
:imap expr buffer ( …

regards,
Christian

-- 
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: Conditional imap

2010-06-29 Thread gitterrost4

Indeed it was latex-suite overriding the map from my tex.vim file. I fixed
this by appending the line

exe 'source '.fnameescape('~/.vim/ftplugin/tex.vim')

to the file $VIM/ftplugin/latex-suite/main.vim

I do not know, if this could be solved better, but now it works...

I also had to adapt the matching, because your suggestion would only match
if the cursor was between math characters, but not if the cursor was at the
end of the line or after a math delimiter. It now boiled down to:

inoremap expr ( synIDattr(synID(line('.'), col('.')-1, 1),
name)=~texMath ? \\left( : synIDattr(synID(line('.'), col('.'), 1),
name)=~ texMath ? \\left( : synIDattr(synID(line('.'), col('.')-1, 1),
name)=~Delimiter ? synIDattr(synID(line('.'), col('.')-2, 1),
name)=~Delimiter ? synIDattr(synID(line('.'), col('.')-3, 1),
name)!~texMath ? \\left( : ( : synIDattr(synID(line('.'),
col('.')-2, 1), name)!~texMath ? \\left( : ( : (


Thanks for helping :)
-- 
View this message in context: 
http://old.nabble.com/Conditional-imap-tp29008528p29022437.html
Sent from the Vim - General mailing list archive at Nabble.com.

-- 
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


:set wrap Range

2010-06-29 Thread Paul

It would be cool if we could :set wrap or nowrap on particular lines but not 
others. I tried it already (of course) but it said no range allowed. What do 
you think about adding this feature in a future version perhaps?

--

.

--
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: au BufReadPost * if readonly | set nomodifiable

2010-06-29 Thread Benjamin Fritz
On Tue, Jun 29, 2010 at 2:24 AM, Tony Mechelynck
antoine.mechely...@gmail.com wrote:
 Hm. Just a wild thought (untested): try the following (which assumes
 'nocompatible'):


  if has('autocmd')
        au VimEnter * augroup nomodif
        au VimEnter * au BufReadPost,BufNewFile * if buftype == 
                \ | let l:ma = l:ro | endif
        au VimEnter * augroup END
  endif



Won't work. The problem seen here was a netrw bug that prevented the
'readonly' option from being set properly. This autocmd will still
fail because the readonly option is not being set.

I believe this issue in netrw was fixed, I vaguely remember reading
something on vim_dev. But, I don't recall the version it was fixed in.

Chip?

-- 
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: Conditional imap

2010-06-29 Thread Christian Brabandt
Hi gitterrost4!

On Di, 29 Jun 2010, gitterrost4 wrote:

 Indeed it was latex-suite overriding the map from my tex.vim file. I fixed
 this by appending the line
 
 exe 'source '.fnameescape('~/.vim/ftplugin/tex.vim')
 
 to the file $VIM/ftplugin/latex-suite/main.vim
 
 I do not know, if this could be solved better, but now it works...
 
 I also had to adapt the matching, because your suggestion would only match
 if the cursor was between math characters, but not if the cursor was at the
 end of the line or after a math delimiter. It now boiled down to:
 
 inoremap expr ( synIDattr(synID(line('.'), col('.')-1, 1),
 name)=~texMath ? \\left( : synIDattr(synID(line('.'), col('.'), 1),
 name)=~ texMath ? \\left( : synIDattr(synID(line('.'), col('.')-1, 1),
 name)=~Delimiter ? synIDattr(synID(line('.'), col('.')-2, 1),
 name)=~Delimiter ? synIDattr(synID(line('.'), col('.')-3, 1),
 name)!~texMath ? \\left( : ( : synIDattr(synID(line('.'),
 col('.')-2, 1), name)!~texMath ? \\left( : ( : (

Ok, I admit, I don't understand, why you need to check for 3 columns in 
front of the cursor. But hey, if it works, I won't complain ;)

regards,
Christian
-- 

-- 
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: Conditional imap

2010-06-29 Thread gitterrost4


Ok, I admit, I don't understand, why you need to check for 3 columns in 
front of the cursor. But hey, if it works, I won't complain ;)

Well in the \[ or the $$ environment, I need to check, if there is a
delimiter one space in front of the cursor, a delimiter two before cursor
and a non-math environment before that. Thet's why I need to check 3 columns
before the cursor.
-- 
View this message in context: 
http://old.nabble.com/Conditional-imap-tp29008528p29027684.html
Sent from the Vim - General mailing list archive at Nabble.com.

-- 
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


percentage of vim users running python

2010-06-29 Thread Ted
Hello folks,

I'm wondering if there are some figures somewhere that would provide
some sort of estimate of the percentage of vim users who have python
installed, or would be free of objections to installing it if a module
required it.  I'm working on some vim modules, to be released for
general use, that are threatening to become pretty complicated, and
would prefer to write them in python.  Is it likely that this would
lock out a significant portion of the vim user population?  Is it
frowned upon to use external languages in cases where it's not
entirely necessary?  Python is more or less ubiquitous on linux
installs, but I don't feel like I could guess at how many vim users on
other platforms would be unable or unwilling to install it.

The modules themselves are relatively general purpose; my motivation
to code them in Python stems partly from this very generality: it's
advantageous to have that code available outside of the context of
vim.  I also find that I tend more and more toward a functional
programming style that doesn't work particularly well in vimscript.

Cheers
-Ted

-- 
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: percentage of vim users running python

2010-06-29 Thread AK
On 06/29/2010 09:20 PM, Ted wrote:
 Hello folks,

 I'm wondering if there are some figures somewhere that would provide
 some sort of estimate of the percentage of vim users who have python
 installed, or would be free of objections to installing it if a module
 required it.  I'm working on some vim modules, to be released for
 general use, that are threatening to become pretty complicated, and
 would prefer to write them in python.  Is it likely that this would
 lock out a significant portion of the vim user population?  Is it
 frowned upon to use external languages in cases where it's not
 entirely necessary?  Python is more or less ubiquitous on linux
 installs, but I don't feel like I could guess at how many vim users on
 other platforms would be unable or unwilling to install it.

 The modules themselves are relatively general purpose; my motivation
 to code them in Python stems partly from this very generality: it's
 advantageous to have that code available outside of the context of
 vim.  I also find that I tend more and more toward a functional
 programming style that doesn't work particularly well in vimscript.

 Cheers
 -Ted


Do you mean Vim compiled with python or just python installed on the
system? If I understand right, windown installer for Vim comes with
python compiled into Vim. Same goes for Vim in Ubuntu. On other
distributions, I'm not sure, I believe I heard that Redhat's Vim does
not have Python compiled in.

If you're using python from Vim, it might make sense to use compiled in
interpreter because there's closer integration with Vim rather than
outside interpreter. If you haven't done this already, read :help python.

   -ak

-- 
 Python plugins for vim: outliner, todo list, project manager, calendar,
 expenses tracker, sortable table, and more |
 http://lightbird.net/pysuite/


-- 
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: percentage of vim users running python

2010-06-29 Thread George V. Reilly
On Tue, Jun 29, 2010 at 6:32 PM, AK andrei@gmail.com wrote:
 On 06/29/2010 09:20 PM, Ted wrote:
  I'm wondering if there are some figures somewhere that would provide
  some sort of estimate of the percentage of vim users who have python
  installed, or would be free of objections to installing it if a module
  required it.  I'm working on some vim modules, to be released for
  general use, that are threatening to become pretty complicated, and
  would prefer to write them in python.  Is it likely that this would
  lock out a significant portion of the vim user population?  Is it
  frowned upon to use external languages in cases where it's not
  entirely necessary?  Python is more or less ubiquitous on linux
  installs, but I don't feel like I could guess at how many vim users on
  other platforms would be unable or unwilling to install it.
 
  The modules themselves are relatively general purpose; my motivation
  to code them in Python stems partly from this very generality: it's
  advantageous to have that code available outside of the context of
  vim.  I also find that I tend more and more toward a functional
  programming style that doesn't work particularly well in vimscript.

 Do you mean Vim compiled with python or just python installed on the
 system? If I understand right, windown installer for Vim comes with
 python compiled into Vim. Same goes for Vim in Ubuntu. On other
 distributions, I'm not sure, I believe I heard that Redhat's Vim does
 not have Python compiled in.

 If you're using python from Vim, it might make sense to use compiled in
 interpreter because there's closer integration with Vim rather than
 outside interpreter. If you haven't done this already, read :help python.

The Windows build refers to a Python DLL and will load it if it can find
it. However, Python itself is not included with Windows Vim and must be
separately installed. It must also be the same version of Python (e.g.,
python26.dll) and the DLL must be in the search path, :h python-dynamic

The average Vim user on Windows is, I suppose, somewhat likely to already
have Python, and, if not, will likely be amenable to installing it
-- especially if it gets them some useful Vim extensions.
But this is all supposition; I know of no way to get meaningful numbers on this.
--
/George V. Reilly  geo...@reilly.org  Twitter: @georgevreilly
http://www.georgevreilly.com/blog  http://blogs.cozi.com/tech

-- 
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: percentage of vim users running python

2010-06-29 Thread sc
On Tuesday 29 June 2010 20:20:27 Ted wrote:

 I'm wondering if there are some figures somewhere that would
  provide some sort of estimate of the percentage of vim users
  who have python installed, or would be free of objections to
  installing it if a module required it.  I'm working on some
  vim modules, to be released for general use, that are
  threatening to become pretty complicated, and would prefer to
  write them in python.  Is it likely that this would lock out
  a significant portion of the vim user population?  Is it
  frowned upon to use external languages in cases where it's
  not entirely necessary?  Python is more or less ubiquitous on
  linux installs, but I don't feel like I could guess at how
  many vim users on other platforms would be unable or
  unwilling to install it.

i'd like to count myself among those who like a lean build
with no extra languages compiled in and as few plugins running
as possible

whatever your modules do i would not consider them if they
require a python enabled vim

sc

-- 
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: percentage of vim users running python

2010-06-29 Thread bill lam
I think you need just release your utility program, if people really
want it, they will not mind installing python.  I personally aren't a
fans of python and will not bother to use vim with python albeit
python is installed here in linux.

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

-- 
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