\Left inside C-R=
The following does not work as expected. I wonder whether it is a bug or a feature: cabbr XXX c-R=xyz.Left()cr function! Left() return \Left endfun Instead of repositioning cursor left, I get :[EMAIL PROTECTED] I know It is possible to make it work via feedkeys(), but this [EMAIL PROTECTED] does not make much sense, does it ? I wonder why \Left is nor recognized here as special key ? Is it some sort of bug ? Yakov
syntax and filetype.vim patch for 'initng' config files
This is filetype.vim patch and syntax for initng config files. Initng is bold new replacement for sysv-init, http://initng.thinktux.net Those config files sit under /etc/initng/** and have extension *.i Distinguishing them from other *.i files is easy, they have #!/bin/itype in the 1st line. The syntax file was written by Elan Ruusamäe [EMAIL PROTECTED] and comes from http://glen.alkohol.ee/pld/initng/vim/ Yakov --- filetype.vim2006-08-21 14:46:46.0 + +++ filetype.vim.0012006-08-21 14:19:49.0 + @@ -1250,19 +1250,14 @@ endif endfun - Progress or assembly or initng -au BufNewFile,BufRead *.i call s:FTprogress_asm_initng() + Progress or assembly +au BufNewFile,BufRead *.i call s:FTprogress_asm() -function! s:FTprogress_asm_initng() +function! s:FTprogress_asm() if exists(g:filetype_i) exe setf . g:filetype_i return endif - initng *.i files begin with #!/sbin/itype - if getline(1) ==# '#!/sbin/itype' - setf initng - return - endif This function checks for an assembly comment the first ten lines. If not found, assume Progress. let lnum = 1 initng.vim Description: Binary data
Re: Netrw and cindent
Mark S. Williams wrote: I think I've uncovered an odd bug involving Netrw and the cindent local buffer option for Java files, where cindent is unset under certain conditions. I'm afraid that I don't see this problem; I tried both your examples. Please try v103f from my website: http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs , see Network Oriented Reading, Writing, and Browsing. If this problem continues to occur, then its likely some setting or other plugin is interfering (the latter most likely via an autocmd). Regards, Chip Campbell
Re: any git developper using gvimdiff ?
Christian MICHON wrote: Hi vim-devers, I'm currently trying out git (linux scm) and I have not found yet how to perform a gvimdiff on a file locally modified with the latest commit. Is there a simple/easy way out for this issue ? Any git specialist amond vim-dev who could give me a hint ? Thanks in advance gvimdiff takes two versions of the same file as arguments, so the question boils down to how to get the successive versions of the file?. I don't know git (and on SuSE 9.3 I have no program of that name in my $PATH) but the command-line for gvimdiff is typically something like gvimdiff filename.ext.old filename.ext The answer may be as simple as taking backup copies of your files. Best regards, Tony.
Re: any git developper using gvimdiff ?
which was the logical conclusion I also came too! Thanks for confirming :) I now proceed thru a shell script to checkout previous version and perform gvimdiff asynchronously to git. works like a charm :) On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Christian MICHON wrote: Hi vim-devers, I'm currently trying out git (linux scm) and I have not found yet how to perform a gvimdiff on a file locally modified with the latest commit. Is there a simple/easy way out for this issue ? Any git specialist amond vim-dev who could give me a hint ? Thanks in advance gvimdiff takes two versions of the same file as arguments, so the question boils down to how to get the successive versions of the file?. I don't know git (and on SuSE 9.3 I have no program of that name in my $PATH) but the command-line for gvimdiff is typically something like gvimdiff filename.ext.old filename.ext The answer may be as simple as taking backup copies of your files. Best regards, Tony. -- Christian
returning values from function(ex_func_T args)?
Hello! Are there any common method to return values from ex_func_T type functions which are defined in CMD_index in ex_cmds.h (external command handlers - say perl/ruby and etc)? I would like to return function execution result to calling script - say string, or list. Thanks in advance, Gaspar
Re: returning values from function(ex_func_T args)?
Gaspar Chilingarov wrote: Hello! Are there any common method to return values from ex_func_T type functions which are defined in CMD_index in ex_cmds.h (external command handlers - say perl/ruby and etc)? I would like to return function execution result to calling script - say string, or list. Thanks in advance, Gaspar IIUC, ex_func_t means void *, i.e., a pointer to anything. You would still need to know what type of object (a pointer to what) the function you're calling is actually returning. If what you are interested in writing is a Vim/perl/ruby/tcl/python/mzscheme script and not a C/C++ source file, you should look in the Vim help rather than in the Vim source. If you are calling a Perl function from Vim, see :help if_perl.vim. If you are calling a Vim function from Perl, look there and also in the help item for the function you're calling. An Ex-command is not the same as a function: a function _may_ have some side-effects (execute an action), it _always_ returns a result (which is the number zero if a :return statement without arguments is executed, or if control falls through to the :endfunction statement. An Ex-command may execute some action and/or display a status message, it does not return a result. To intercept errors generated in Vim, you can use the try/catch/finally/endtry mechanism (see :help :try). To ignore them, use :silent (q.v.) Best regards, Tony.
Re: returning values from function(ex_func_T args)?
Hi all! IIUC, ex_func_t means void *, i.e., a pointer to anything. You would still need to know what type of object (a pointer to what) the function you're calling is actually returning. well, I'm going to write if_* script to integrate vim with erlang -- so I need to pass arguments/variables to erlang runtime sistem, and get them back -- there is almost one-to-one mapping from erlang data structures to vim . If what you are interested in writing is a Vim/perl/ruby/tcl/python/mzscheme script and not a C/C++ source file, you should look in the Vim help rather than in the Vim source. ---skip--- no, I'm going to write C code :) -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e [EMAIL PROTECTED]
Re: returning values from function(ex_func_T args)?
Gaspar Chilingarov wrote: Hi all! IIUC, ex_func_t means void *, i.e., a pointer to anything. You would still need to know what type of object (a pointer to what) the function you're calling is actually returning. well, I'm going to write if_* script to integrate vim with erlang -- so I need to pass arguments/variables to erlang runtime sistem, and get them back -- there is almost one-to-one mapping from erlang data structures to vim . If what you are interested in writing is a Vim/perl/ruby/tcl/python/mzscheme script and not a C/C++ source file, you should look in the Vim help rather than in the Vim source. ---skip--- no, I'm going to write C code :) Yeah, I saw your other post after posting this answer. Well, Vim (and the vim-script language) defines the following kinds of objects: - data items - Strings and Numbers, which Vim can translate into each other - Number to String doesn't lose information - String to Number converts only what precedes the first non-number (defaul is zero) - Booleans are a special kind of Number (zero=FALSE, nonzero=TRUE) - Lists - Dictionaries - buffers, windows, tab pages - functions - a function takes a fixed or variable number of arguments depending on the function - a function may optionally have side-effects within Vim - a function returns a value, which may be any data item; - by default (return without argument, or fall thru to endfunction) the return value is the Number 0 - a function may trigger an error - Ex-commands - an Ex-command usually does some action - see :help :command and scroll to Command attributes for the different kinds of arguments, w/wo range, w/wo count, etc. - an Ex-command may trigger an error - an Ex-command may optionally display something on the command-line - an Ex-command does not return a value. In the case of the existing interpreted languages (perl, python, ruby, Tcl and Mzscheme): - Vim can - invoke the interpreter for inline scripts - invoke the interpreter for individual commands - invoke the interpreter for every line in a range - since the interpreter has access to Vim variables, the above can change variables and thus return a result - The interpreter can access most Vim variables, functions, commands and data structures via extensions to the interpreter syntax. You may want to run Exuberant ctags in the src/ directory containing the Vim source, and possibly in whichever include directories are mentioned on the compile command line (as shown by :version). This will allow you to go from any word in the source to its definition, see :help tagsrch.txt. To go _from_ the definition _to_ the use(s) you may have to use the :vimgrep command (q.v.) (assuming you have Vim 7). You may also want to read attentively the following, to see how the existing interfaces do it (assuming the src directory is current): :help if_perl.txt :view if_perl.xs :view auto/if_perl.c :view if_perlsfio.c :view proto/if_perl.pro :view proto/if_perlsfio.pro note: if_perl.c is generated from if_perl.xs when you make Vim. :help if_python.txt :view if_python.c :view if_python.pro :help if_ruby.txt :view if_ruby.c :view if_ruby.pro :help if_tcl.txt :view if_tcl.c :view if_tcl.pro :help if_mzsch.txt :view if_mzsch.c :view if_mzsch.pro :view if_mzsch.h :view eval.c etc. Best regards, Tony.
Re: Problem with completion
Hi Srinath, For now, I am just going to set noignorecase to get around this, but it would be nice if this were fixed. On another note, I would like an option which only ignores case when searching. When doing completion, I have taken the trouble of typing Graph with a capital G, so I don't want case to be ignored. Is there a way to do this? Aah... there is... 'smartcase'. Cool... That seems to partly solve the problem. It works when I have atleast one upper case character typed before I press C-p. Doesn't completely solve it though. This probably won't make you perfectly happy either, but you can also use '\c' in the search string to force ignore-case, or '\C' to force case-matching. See ':help /\c' for more info. regards, Peter On Yahoo!7 The new Yahoo!7 home page - scan your email inbox, start an IM conversation or update your blog http://au.yahoo.com/
Re: Omnicompletion top window
On 8/21/06, Panos Laganakos [EMAIL PROTECTED] wrote: Although, doesn't it make sense to make it go away, once you type something else except Ctr_X or Ctr_O to move up or down? Yes. IMHO I would have to agree that it will be prefect if the preview window is another popup near the completing word, and have the intelligence to close itself automatically once the user is done with it. Back to the old time there isn't any preview nor omni-completion. So I'm happy with it. :) Maybe it can be an add-on feature for the next release? Personally I tried using the preview window but it started up slow in my computer @ home. So I remove it from 'cot' option. If you prefer, can map c-wc-z to a shortcut you like. Maybe i_Ctrl-x_Ctrl-w? or simply i_Ctrl-L if you don't use it. imap c-xc-w c-yesc:pccra HTH, -- Ed
Re: having a function within an abbreviation
On 8/21/06, Edward Wong [EMAIL PROTECTED] wrote: Dear all, I'm trying to accomplish sth similar as follow: ca grf C-R=(getcmdpos() == 1 getcmdtype() == ':' ? 'grep -i ' . expand(%:f) . ^V^VC-Left^V^VLeft : grf)CR Hello Edward, ca grf C-R=(getcmdpos() == 1 getcmdtype() == ':' ? 'grep -i ' .expand(%:f) . Reposition() : 'grf')CR function! Reposition() call feedkeys(\C-Left\Left) return endfun Requires vim7. Yakov
saving unnamed buffer
I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun
Re: saving unnamed buffer
Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. Best regards, Tony.
Re: saving unnamed buffer
On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. Nope, does not help. Yakov
Re: saving unnamed buffer
On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov
Re: having a function within an abbreviation
On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: ca grf C-R=(getcmdpos() == 1 getcmdtype() == ':' ? 'grep -i ' .expand(%:f) . Reposition() : 'grf')CR function! Reposition() call feedkeys(\C-Left\Left) return endfun Thanks Yakov! It works. :) I still don't understand why ^V^V^M or ^V^V^R don't work, according to the help book :h using_ctrl-v Ed
Re: saving unnamed buffer
Yakov Lerner wrote: On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov Well, what gets displayed when you replace exe by echo or echomsg? That's a well-known debugging trick. Best regards, Tony.
Re: saving unnamed buffer
Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: saving unnamed buffer
On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. not good. Yakov
Re: saving unnamed buffer
On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov Well, what gets displayed when you replace exe by echo or echomsg? Nothing gets displayed. Jürgen must be right. Yakov
renaming unnamed buffer at creation
Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif Yakov
Re: renaming unnamed buffer at creation
Hi, Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif I checked it with this autocommand au! BufNew * \ if expand('afile') == '' | \ exe 'file ' . input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif It seems to be triggered, but when the 'file' command is executed, VIM is still in the original buffer thus renaming this one instead of the new one. One way to circumvent this problem I can think of is to use the BufNew event to store the new file name in a variable and to use this variable in a BufEnter event. The following code should do this, but it is untested: au! BufNew * \ if expand('afile') == '' | \ let new_file_name = input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif au! BufEnter * \ if expand('afile') == '' exists('new_file_name') | \ exe 'file ' . new_file_name | \ unlet new_file_name | \ endif Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: renaming unnamed buffer at creation
Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif Yakov add for debugging echo afile | before the if. If it still doesn't work, add nested to the autocommand. Best regards, Tony.
E505, File is write-protected
Hi vimmers, when I try to write (:w) a certain buffer, I get E505 (~ file XXX is write-protected, override with w!). The protection seems to be set by Vim, not the OS (WinXP). So I looked for the readonly option value, but it's set to noreadonly. I also checked write, which is set to write. Nevertheless, everytime I try to :w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on Win XP) Thanx in advance Wolfgang
Re: renaming unnamed buffer at creation
Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. Hello! The autocmd system is always invoked based on the buffer name. Thus it appears none of the autocmds will fire, including BufWriteCmd, BufReadCmd, CursorHold, etc. The only alternative that I can think of is to use maps, for example, try to catch a newline in insert mode. Regards, Chip Campbell
Re: E505, File is write-protected
Hi, Wolfgang Schmidt wrote: when I try to write (:w) a certain buffer, I get E505 (~ file XXX is write-protected, override with w!). The protection seems to be set by Vim, not the OS (WinXP). So I looked for the readonly option value, but it's set to noreadonly. I also checked write, which is set to write. Nevertheless, everytime I try to :w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on Win XP) are you able to write the file with :w!? If not, the file might be opened exclusively or with write-access denied by another program. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: renaming unnamed buffer at creation
Hi, Charles E Campbell Jr wrote: Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. The autocmd system is always invoked based on the buffer name. Thus it appears none of the autocmds will fire, including BufWriteCmd, BufReadCmd, CursorHold, etc. :au BufNew * echo 'File name is ' . expand('afile') . '.' is fired for empty buffer names, too, and will output File name is . in this case. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: E505, File is write-protected
Wolfgang Schmidt wrote: when I try to write (:w) a certain buffer, I get E505 (~ file XXX is write-protected, override with w!). The protection seems to be set by Vim, not the OS (WinXP). So I looked for the readonly option value, but it's set to noreadonly. I also checked write, which is set to write. Nevertheless, everytime I try to :w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on Win XP) are you able to write the file with :w!? If not, the file might be opened exclusively or with write-access denied by another program. Regards, Jürgen With :w! the file can be written, so this can't be the problem. Thanks, though ... Wolfgang
Re: renaming unnamed buffer at creation
Charles E Campbell Jr wrote: Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. Hello! The autocmd system is always invoked based on the buffer name. Thus it appears none of the autocmds will fire, including BufWriteCmd, BufReadCmd, CursorHold, etc. The only alternative that I can think of is to use maps, for example, try to catch a newline in insert mode. Regards, Chip Campbell With * as the pattern, the autocommand _is_ triggered, but... Experiment: 1. Define an autocommand :au BufAdd * echo New buffer: expand(afile) 2. Trigger it :new New buffer: :new dummy New buffer: dummy dummy [New File] Reading viminfo file /root/.viminfo marks expand() is necessary, otherwise I get errors culminating in E15 Invalid expression Best regards, Tony.
Re: renaming unnamed buffer at creation
On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif I checked it with this autocommand au! BufNew * \ if expand('afile') == '' | \ exe 'file ' . input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif It seems to be triggered, but when the 'file' command is executed, VIM is still in the original buffer thus renaming this one instead of the new one. One way to circumvent this problem I can think of is to use the BufNew event to store the new file name in a variable and to use this variable in a BufEnter event. The following code should do this, but it is untested: au! BufNew * \ if expand('afile') == '' | \ let new_file_name = input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif au! BufEnter * \ if expand('afile') == '' exists('new_file_name') | \ exe 'file ' . new_file_name | \ unlet new_file_name | \ endif Regards, Jürgen Why not change to the new buffer? Something like: :au BufAdd * if expand('afile')==''|execute 'buffer' expand('abuf')|execute 'file' tempname()|endif
Re: E505, File is write-protected
Wolfgang Schmidt wrote: Wolfgang Schmidt wrote: when I try to write (:w) a certain buffer, I get E505 (~ file XXX is write-protected, override with w!). The protection seems to be set by Vim, not the OS (WinXP). So I looked for the readonly option value, but it's set to noreadonly. I also checked write, which is set to write. Nevertheless, everytime I try to :w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on Win XP) are you able to write the file with :w!? If not, the file might be opened exclusively or with write-access denied by another program. Regards, Jürgen With :w! the file can be written, so this can't be the problem. Thanks, though ... Wolfgang Then the file might be write-protected by Windows (any program can override that if it takes extra steps for it). Try attrib filename.ext in CMD.EXE (where filename.ext is the name of the file). There are four possible attributes, each of which may either appear or be replaced by a space or period: H hidden : doesn't appear in DIR listings S system : a special kind of hidden file R readonly : the file cannot be written, except by clearing this flag first A archive : the file has been archived. To be normally writable, the file should have either no flags at all, or else only A. To change the flags, use for instance attrib -R +A filename.ext (minus to clear, plus to set). Best regards, Tony.
Re: E505, File is write-protected
Wolfgang Schmidt wrote: A.J.Mechelynck wrote: Then the file might be write-protected by Windows (any program can override that if it takes extra steps for it). Try attrib filename.ext in CMD.EXE (where filename.ext is the name of the file). There are four possible attributes, each of which may either appear or be replaced by a space or period: H hidden : doesn't appear in DIR listings S system : a special kind of hidden file R readonly : the file cannot be written, except by clearing this flag first A archive : the file has been archived. To be normally writable, the file should have either no flags at all, or else only A. To change the flags, use for instance attrib -R +A filename.ext (minus to clear, plus to set). Best regards, Tony. Thanx Tony, but this didn't work either. I executed attrib -R +A filename.ext as proposed, but still got the described behaviour. I have closed my Gvim session now and retried all with console vim. So I executed the attrib command as proposed, so the file's attribute is now set to A. I then started a console Vim to edit the file. The file was marked as [RO] when loading, so the readonly was set. I reset it with :set noreadonly and the [RO] mark disappeared. After this I again tried writing the file with :w, and again I got this E505 Message. Why does Vim think, this file would be [RO]? Wolfgang I don't know. I'm sending this to the list so someone else may answer. (Please use Reply to all next time.) Best regards, Tony.
using counter prefix in a map/command
I did the following command to open man pages inside Vim: nmap K :Man C-RC-WCR command! -bar -nargs=1 DoMan %!/usr/bin/man -P cat args command! -bar -nargs=1 Man \ new \| DoMan args \| %s/.^H//g \| set filetype=man \| goto 1 \| set buftype=nofile It works nice, but I want also to be able to specify the man section, mas many C commands are also bash or shell commands, like exit, stat, and so on. I'm sure it's written in the extensive online documentation, but my lazyless is greater then my shame to ask it here. :) -- Rodolfo Borges
Re: E505, File is write-protected - Problem solved
I don't know. I'm sending this to the list so someone else may answer. (Please use Reply to all next time.) Best regards, Tony. I got rid of the problem finally now by - rebooting. I looks like another nice feature of this obscure NTFS file system. Thanx Tony and Jürgen for your proposals, Wolfgang
Re: renaming unnamed buffer at creation
On 8/21/06, Bob Hiestand [EMAIL PROTECTED] wrote: On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif I checked it with this autocommand au! BufNew * \ if expand('afile') == '' | \ exe 'file ' . input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif It seems to be triggered, but when the 'file' command is executed, VIM is still in the original buffer thus renaming this one instead of the new one. One way to circumvent this problem I can think of is to use the BufNew event to store the new file name in a variable and to use this variable in a BufEnter event. The following code should do this, but it is untested: au! BufNew * \ if expand('afile') == '' | \ let new_file_name = input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif au! BufEnter * \ if expand('afile') == '' exists('new_file_name') | \ exe 'file ' . new_file_name | \ unlet new_file_name | \ endif Regards, Jürgen Why not change to the new buffer? Something like: :au BufAdd * if expand('afile')==''|execute 'buffer' expand('abuf')|execute 'file' tempname()|endif This is nice, but. This works for :new (I tried BufNew), but still does not work for that empty buffer #1 that is created when vim is invoked without commandline arguments. I want it to work for the initial empty buffer, too. Yakov
Re: using counter prefix in a map/command
Rodolfo Borges wrote: I did the following command to open man pages inside Vim: nmap K :Man C-RC-WCR command! -bar -nargs=1 DoMan %!/usr/bin/man -P cat args command! -bar -nargs=1 Man \ new \| DoMan args \| %s/.^H//g \| set filetype=man \| goto 1 \| set buftype=nofile It works nice, but I want also to be able to specify the man section, mas many C commands are also bash or shell commands, like exit, stat, and so on. I'm sure it's written in the extensive online documentation, but my lazyless is greater then my shame to ask it here. :) Prefix the argument with the section name (1 character) or with -a for all sections, or with -S list where list is a semicolon-separated ordered list of section. Since DoMan (and Man) accept only one argument, separating spaces must be escaped, which means you cannot do it with the above K mapping. Best regards, Tony.
Re: renaming unnamed buffer at creation
Yakov Lerner wrote: On 8/21/06, Bob Hiestand [EMAIL PROTECTED] wrote: On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, Yakov Lerner wrote: Now that my attempt to write unnamed buffer under name /tmp/N failed, I want to autoname empty buffer. My first attempt does not work. Autoevent is ot invoked. function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun au BufNew * if(expand('afile') == '') | call input(AAA) | endif au BufNew * if(expand('afile') == '') | exe file .TempName() | endif I checked it with this autocommand au! BufNew * \ if expand('afile') == '' | \ exe 'file ' . input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif It seems to be triggered, but when the 'file' command is executed, VIM is still in the original buffer thus renaming this one instead of the new one. One way to circumvent this problem I can think of is to use the BufNew event to store the new file name in a variable and to use this variable in a BufEnter event. The following code should do this, but it is untested: au! BufNew * \ if expand('afile') == '' | \ let new_file_name = input('Enter file name: ') | \ else | \ echomsg 'File already has a name' | \ endif au! BufEnter * \ if expand('afile') == '' exists('new_file_name') | \ exe 'file ' . new_file_name | \ unlet new_file_name | \ endif Regards, Jürgen Why not change to the new buffer? Something like: :au BufAdd * if expand('afile')==''|execute 'buffer' expand('abuf')|execute 'file' tempname()|endif This is nice, but. This works for :new (I tried BufNew), but still does not work for that empty buffer #1 that is created when vim is invoked without commandline arguments. I want it to work for the initial empty buffer, too. Yakov IIUC, that buffer is created before sourcing the vimrc (at step 2 under :help startup), so apparently you're out of luck there. Try either BufWriteCmd (q.v.) or BufWinEnter (but the latter will be triggered too often, and your if will return FALSE except maybe the first time). Best regards, Tony.
Mapping Alt_Shift on Vim windows
Hello, My problem is this: I am used to pressing Alt_Shift in order to switch languages on windows, but Doing so in Vim will just change language without changing keymap. That results in me not being able to use Vim as keybindings don't work etc. I'd like to know how it'll be possible to map Alt_Shift to set keymap=Greek if None and None if Greek. Thanks. -- Panos Laganakos
Re: using counter prefix in a map/command
On 8/21/06, Rodolfo Borges [EMAIL PROTECTED] wrote: I did the following command to open man pages inside Vim: nmap K :Man C-RC-WCR command! -bar -nargs=1 DoMan %!/usr/bin/man -P cat args command! -bar -nargs=1 Man \ new \| DoMan args \| %s/.^H//g \| set filetype=man \| goto 1 \| set buftype=nofile It works nice, but I want also to be able to specify the man section, Your question is not exactly clear. If you want to invoke K or :Man with count like 3K :3Man ... where you want to use count as section number, then look into :help count (this count will be 0 if not supplied). If you ask something else, please clarify your question. Yakov
TempName() and swapfiles
I'm generating short temp names like /tmp/N or ~/tmp/N where N is number. My first take on the TempName() function was: function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Surprising problem came up. vim#1 choose name /tmp/3 and swapfile for /tmp/3 exists (/tmp/.3.swp) but file /tmp/3 does not exists. As a result, vim#2 tries to use /tmp/3. I am modifying my TempName() to check explicitly for /tmp/.3.swp, but I maybe we need a function in vim that check whether file x has swapfiles ? I don't find such function. The builtin function can take correctly into account various settings associated with swapfile naming, no ? Is there better solution to check that file x has/does not have swapfiles ? Yakov
Re: saving unnamed buffer
On 2006-08-21, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. not good. How about trying the BufWriteCmd event instead? Maybe it doesn't check the buffer name. HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: using counter prefix in a map/command
Rodolfo Borges wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Since DoMan (and Man) accept only one argument, separating spaces must be escaped, which means you cannot do it with the above K mapping. Oh, really? I never thought such a thing (that is, you cannot do something) would be possible with Vim. Anyway, thanks for the man -S tip, it's a nice workaround. Best regards, Oh, you may change the mapping, or maybe make another one, to include a count. But what to do with map sections whose names are not digits? (e.g. section n as in man n uuencode). OTOH you can use :Map n\ uuencode or maybe Map n\\\ uuencode and get it. Best regards, Tony.
Re: Mapping Alt_Shift on Vim windows
Panos Laganakos wrote: Hello, My problem is this: I am used to pressing Alt_Shift in order to switch languages on windows, but Doing so in Vim will just change language without changing keymap. That results in me not being able to use Vim as keybindings don't work etc. I'd like to know how it'll be possible to map Alt_Shift to set keymap=Greek if None and None if Greek. Thanks. Alt-Shift with nothing else (i.e., not Alt-Shift-Space or Alt-Shift-F1 or...) is never seen by Vim. Vim uses cooked keyboard input; pressing or releasing Shift/Ctrl/Alt changes a status bit somewhere but in that case the keypress/key-release event doesn't make it into the keyboard buffer. You can try mapping Alt-Shift-F1 or something like that. Example: map M-S-F1 :let imi = ! imiCR map! M-S-F1 C-^ Best regards, Tony.
Re: renaming unnamed buffer at creation
On 2006-08-21, Yakov Lerner [EMAIL PROTECTED] wrote: This is nice, but. This works for :new (I tried BufNew), but still does not work for that empty buffer #1 that is created when vim is invoked without commandline arguments. I want it to work for the initial empty buffer, too. I had a similar problem with a plugin I was writing recently. Without going into details on the plugin, here's what I did to make sure a particular function was called no matter how I started vim. Call the ConfigureProject() function when Vim is started and when a new file is opened. let b:event = '' if argc() == 0 No files were specified on the command line, so the autocommand will not be triggered when vim starts. call ConfigureProject('') endif if argc() 0 isdirectory(argv(0)) The first file specified on the command line is a directory, so the autocommand will not be triggered when vim starts. call ConfigureProject(fnamemodify(argv(0), :p)) endif augroup project au! au BufNewFile * let b:event=BufNewFile | call ConfigureProject(expand(afile:p:h)) au BufRead* let b:event=BufRead| call ConfigureProject(expand(afile:p:h)) augroup END HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
How do one open files for editing from a function?
Hi again I have another question... I'm trying to make a function to open files for editing from a function. however I keep getting an error. I have included a very simple functions that gives the same error message. I understand that one cannot do it this way, but I don't know how to do it: function! Read_test() execute e somefile endfunction I get this error: E127: Cannot redefine function Read_test: It is in use Any hints much appreciated Preben
Re: TempName() and swapfiles
Yakov Lerner wrote: I'm generating short temp names like /tmp/N or ~/tmp/N where N is number. My first take on the TempName() function was: function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Surprising problem came up. vim#1 choose name /tmp/3 and swapfile for /tmp/3 exists (/tmp/.3.swp) but file /tmp/3 does not exists. As a result, vim#2 tries to use /tmp/3. I am modifying my TempName() to check explicitly for /tmp/.3.swp, but I maybe we need a function in vim that check whether file x has swapfiles ? I don't find such function. The builtin function can take correctly into account various settings associated with swapfile naming, no ? Is there better solution to check that file x has/does not have swapfiles ? Yakov Checking for (any) swapfile would mean check for more than just /tmp/3.swp since if file.swp exists and you reply 'Edit anyway' to the ATTENTION message, Vim will use file.swo, then file.swn, ... It may go back to .saa (see :help swap-file). OTOH the swap file is not always in the same directory as the file, and if the file was edited by a different Vim, they may have different 'directory' settings. IIUC, the nearest to a hasswap() function you can get is to run :!vim -r in the directory where you plan to open the file, and parse the output. Maybe an appropriate 'errorformat' can be contrived to regard that output as a quickfix error list, but I'm not a specialist of such matters. Best regards, Tony.
Re: How do one open files for editing from a function?
On 2006-08-21, A.J.Mechelynck [EMAIL PROTECTED] wrote: Preben Randhol wrote: Hi again I have another question... I'm trying to make a function to open files for editing from a function. however I keep getting an error. I have included a very simple functions that gives the same error message. I understand that one cannot do it this way, but I don't know how to do it: function! Read_test() execute e somefile endfunction I get this error: E127: Cannot redefine function Read_test: It is in use Any hints much appreciated Preben The function definition must not be in a script or function which is called from an autocommand which is triggered by opening a file for editing. There are a number of ways you (Preben) can get around that. Not knowing exactly what you're trying to do, I don't know which to suggest, but here's one solution: if !exists(*Read_test) function Read_test() execute e somefile endfunction endif HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Email Text Formatter Plugin
Forgive me if this is a terribly simple question, but I searched for a while and couldn't find the solution to this problem. I'm looking for a simple function that will reformat a selected block of text for e-mail messages (80 columns long, preserving characters, etc). Vim Cream can do this very well, but the functionality doesn't easily translate to vanilla Vim from what I can see, and I prefer using Vim instead of Cream. Is there a function that allows me to do this for Vim? Thanks in advance! Tom Purl
Re: Email Text Formatter Plugin
On Mon, 2006-08-21 at 20:54:21 -0500, Tom Purl sent: I'm looking for a simple function that will reformat a selected block of text for e-mail messages (80 columns long, preserving characters, etc). Vim Cream can do this very well, but the functionality doesn't easily translate to vanilla Vim from what I can see, and I prefer using Vim instead of Cream. Is there a function that allows me to do this for Vim? Have you tried 'gq'? This works perfectly for me with visual blocks. See: :help gq Hope this helps; --paj -- Pete Johns http://johnsy.com/ Contact Information http://johnsy.com/contact/ Taking Stock http://johnsy.com/20060821101816 dsc00220 http://johnsy.com/albums/flickr/210370644 pgpFAXUjYY1i8.pgp Description: PGP signature
Re: Email Text Formatter Plugin
Thanks a ton! This works very well. On Tue, Aug 22, 2006 at 12:08:50PM +1000, Pete Johns wrote: On Mon, 2006-08-21 at 20:54:21 -0500, Tom Purl sent: I'm looking for a simple function that will reformat a selected block of text for e-mail messages (80 columns long, preserving characters, etc). Vim Cream can do this very well, but the functionality doesn't easily translate to vanilla Vim from what I can see, and I prefer using Vim instead of Cream. Is there a function that allows me to do this for Vim? Have you tried 'gq'? This works perfectly for me with visual blocks. See: :help gq Hope this helps; --paj -- Pete Johns http://johnsy.com/ Contact Information http://johnsy.com/contact/ Taking Stock http://johnsy.com/20060821101816 dsc00220 http://johnsy.com/albums/flickr/210370644
Re: Email Text Formatter Plugin
On Mon, Aug 21, 2006 at 10:08:50PM EDT, Pete Johns wrote: On Mon, 2006-08-21 at 20:54:21 -0500, Tom Purl sent: I'm looking for a simple function that will reformat a selected block of text for e-mail messages (80 columns long, preserving characters, etc). Vim Cream can do this very well, but the functionality doesn't easily translate to vanilla Vim from what I can see, and I prefer using Vim instead of Cream. Is there a function that allows me to do this for Vim? Have you tried 'gq'? This works perfectly for me with visual blocks. Someone on the list recently suggested I use gqip to reflow paragraphs and I was going to suggest that. Much to my delight, I later found that it also preserved the characters in e-mail messages, so I was going to recommend using that. I find it quicker than entering visual mode. This thread made me realize that I do not even understand how gqip works..? :h gq tells me that the general format is gq{motion} .. but what kind of motion is ip..? i should move the cursor up just one line but what about p..? Thanks cga
Re: Email Text Formatter Plugin
On Mon, 2006-08-21 at 23:47:56 -0400, cga2000 sent: Someone on the list recently suggested I use gqip to reflow paragraphs and I was going to suggest that. Much to my delight, I later found that it also preserved the characters in e-mail messages, so I was going to recommend using that. Indeed. This would work well for a given paragraph. :h gq tells me that the general format is gq{motion} .. but what kind of motion is ip..? i should move the cursor up just one line but what about p..? Close but no cigar. 'k' would move up a line. 'ip' is Inner Paragraph. See: :he ip :he object-motions will help you speed up your Vim usage. Best; --paj -- Pete Johns http://johnsy.com/ Contact Information http://johnsy.com/contact/ Taking Stock http://johnsy.com/20060821101816 dsc00220 http://johnsy.com/albums/flickr/210370644 pgp6qaobD7FeN.pgp Description: PGP signature
Re: UTF-8 Problem with Localization in Windows GVIM
On 8/20/06, Yongwei Wu [EMAIL PROTECTED] wrote: This is really an old problem. It begins with VIM 6. While it is possible to set encoding=UTF-8 on Windows to be able to process text file in multiple encodings at the same time, the localized menu/messages has problems. The simplest _vimrc one may think of will render anything except the menu incorrect: set encoding=utf-8 source $VIMRUNTIME/vimrc_example.vim Reverse the order of these two lines will make the tool tips of the toolbar buttons correct, but the menu will be corrupt, as well as all the localized messages. The best I can get is with this _vimrc (simplified): source $VIMRUNTIME/vimrc_example.vim set encoding=utf-8 lang messages zh_CN.UTF-8 runtime! delmenu.vim In the time of Vim 6, it works well, except the tool tips for the toolbar buttons. I have to disable the toolbar translations in menu_zh_cn.utf-8.vim to make it work perfectly. With the new tab support in Vim 7, more headaches come. When I use localized messages, the context menu on the tabs (Close tab, New tab, and Open tab ...) is corrupt and the text is unreadable. Since the translation seems not in a .vim file, I find nowhere to fix it. Editing vim.mo might work, but it seems too incovenient and unreliable. The problem, as it seems to me, is that the context menu on the tab and the tool tips for the toolbar buttons only support the `ANSI' encoding. Any fixes/hacks to make it work? I knew that. I'll debug it soon. Before I hack out this problem, you can still do some blaming work to Micro$oft for its *so wonderful* multilinguagiation mechanics. I'm sorry but I'm not going to work out this problem for Vim6. So you'll have to upgrade to Vim7 even if I could solve the problem... Best regards, Yongwei -- Wu Yongwei URL: http://wyw.dcweb.cn/ Regards, Edward L. Fox
Re: Email Text Formatter Plugin
On Mon, Aug 21, 2006 at 11:55:54PM EDT, Pete Johns wrote: On Mon, 2006-08-21 at 23:47:56 -0400, cga2000 sent: Someone on the list recently suggested I use gqip to reflow paragraphs and I was going to suggest that. Much to my delight, I later found that it also preserved the characters in e-mail messages, so I was going to recommend using that. Indeed. This would work well for a given paragraph. :h gq tells me that the general format is gq{motion} .. but what kind of motion is ip..? i should move the cursor up just one line but what about p..? Close but no cigar. 'k' would move up a line. 'ip' is Inner Paragraph. See: :he ip :he object-motions will help you speed up your Vim usage. Best; --paj gotcha .. :-( and thanks much for your last tip.. or pointing me in the right direction I should say..! Thanks cga
% does not work with ' ( '
Hello, Is there any way to make % jump to the correct parenthesis and ignore a '(' inside a single-quoted string? For example: if('string(string') Pressing % while the cursor is at the end of the line will jump to the wrong '('. Is there any way to fix this? The help page on % does not mention any way to make % skip over single-quoted strings unless '(' is the whole string. regards, Peter On Yahoo!7 The new Yahoo!7 home page - scan your email inbox, start an IM conversation or update your blog http://au.yahoo.com/