Tuesday, June 29, 2010

Re: au BufReadPost * if &readonly | set nomodifiable

On Tue, Jun 29, 2010 at 2:24 AM, Tony Mechelynck
<antoine.mechelynck@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

:set wrap Range

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

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

Re: Conditional imap

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

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

On 06/05/10 22:26, Ben Fritz wrote:
>
>
> On May 6, 1:22 pm, rudy_b<rudyke...@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 * if&readonly | set nomodifiable | endif
>> autocmd BufRead,BufWinEnter * if&ft!='qf' | let&l: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, Jr<NdrOchip@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

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