Re: end of line whitespace
Robert Hicks wrote: I know that in some IDE's I can check a box that causes the IDE to automatically strip trailing white space. Does Vim have a switch to do that or do I need to do: autocmd BufWritePre * %s/\s*$//e It would be nice to have a "set stripwhitespace" if that is the case but I guess that is the power of Vim. Robert AFAIK there is no such setting, but your autocommand is the next best thing. OTOH you can _see_ end-of-line whitespace by setting the 'list' and 'listchars' options appropriately. For instance, :set list listchars=tab:\ \ ,eol:$ displays the files as usual, but with a blue dollar sign (well, blue by default: a colorscheme can change that) just after the last character on each line. Best regards, Tony
end of line whitespace
I know that in some IDE's I can check a box that causes the IDE to automatically strip trailing white space. Does Vim have a switch to do that or do I need to do: autocmd BufWritePre * %s/\s*$//e It would be nice to have a "set stripwhitespace" if that is the case but I guess that is the power of Vim. Robert
Re: Any way of getting statusline=%B in insert mode?
Bill McCarthy wrote: [...] Perhaps. It behaves that way (also in 6.4) for both %b and %B. In Gvim, the cursor is between 2 characters - so returning zero for %b and %B seems reasonable. OTOH, supporting the bug conclusion, the character position of %c, %v and %V report the position following the between character cursor. In (g)vim, the cursor is never between characters. In gvim, with the default setting for 'guicursor', the cursor looks as if it were between characters, because it is drawn as a vertical bar occupying the leftmost 25% of its character cell; but ":set guicursor=a:block-Cursor" will show that it is indeed within a character cell (whose position is reported by %c %v %V). Best regards, Tony.
Re: surrparen
On 2007-01-02, AOYAMA Shotaro <[EMAIL PROTECTED]> wrote: > Hi, > > Now I'm writing a plugin that hilights a pair of > parens/braces which surround the cursor position. > Unlike matchparen.vim, it works even when the cursor > is not just on a paren/brace. > The attached file is the source. > > But I have noticed a bothering problem with it. > > When cursor is on '0' in the following text, > | > v > do_all = (flags[0] == 'g'); > > do_all = (flags[1] == 'g'); > > you press jj, then the cursor normally should down > two lines and on '1'. > But when using this plugin, it goes the first column. > > I'm wondering how I can avoid this problem. > Any ideas? > and any other suggestion is welcome. Does your plugin use the CursorHold or CursorMoved autocommand? Does your plugin move the cursor after the user has moved it, then restore the user's cursor position? Normally, vim remembers that your cursor was in column 17 (over the 'O') when you moved it to the empty line and moves the cursor back to column 17 when you move it again to the next line having 17 or more columns. If, when the cursor is at the first column of that blank line, your plugin executes a command that remembers the cursor position, moves the cursor someplace else, then restores the cursor position, vim thinks the user has deliberately moved the cursor to column 1 and uses that "desired column number" when the user subsequently moves the cursor to the next line. This leaves the cursor in column 1 when you think it should have moved back to column 17. I think this problem can be solved by using the winsaveview() function to save the cursor and view information before moving the cursor, then using the winrestview() function to restore the cursor and view. These functions are new with vim 7.0 and I haven't tried them yet. HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: Any way of getting statusline=%B in insert mode?
On Tue 2-Jan-07 12:57pm -0600, A.J.Mechelynck wrote: > DervishD wrote: >> Hi all, and happy new year! >> >> I have %B in my status line, but it doesn't work in insert mode, >> only on normal and visual mode. At first I thought that the status line >> wasn't being evaluated while in insert mode, but the line and column >> numbers change correctly, so it *is* being evaluated, it's just that %B >> doesn't seems to work. >> >> Any way of working around this problem? Is this a feature? >> >> Thanks a lot in advance :) >> >> Raúl Núñez de Arenas Coronado >> > > I confirm that in Insert/Replace mode %B gives a single digit zero. In Select > mode it works OK, even in Select (insert) i.e. when triggered by hitting > shift-arrow in Insert mode. > > Even in Insert mode, the display is OK in non-current windows (e.g. clicking a > status line or using Ctrl-O Ctrl-W w to change windows, gives a correct > display on the status line of the window which we just left). > > IMHO this is a bug. Perhaps. It behaves that way (also in 6.4) for both %b and %B. In Gvim, the cursor is between 2 characters - so returning zero for %b and %B seems reasonable. OTOH, supporting the bug conclusion, the character position of %c, %v and %V report the position following the between character cursor. -- Best regards, Bill
Re: Syntax highlighting
cupaxe wrote: Is there a way to have different (see below) syntax highlighting for different portions of a file? What I am interested in knowing is whether there exists a meta file format (say multisyn) which highlights different portions of a file with syntax corresponding to that portion. For instance, let the file multisyn.cat be the following- Start of multisyn.cat +++ #!/usr/bin/perl print "Hello world\n"; foreach $i ( 1 .. 10 ){ print $i,"\n"; } +++ #!/bin/tcsh set hello = "world"; echo $hello +++ End of multisyn.cat What I would like is that each portion of multisyn.cat be highlighted with a different syntax corresponding to that portions file marked by the #!/usr/... indicator. For instance, I would like the first portion to be highlighted using the perl syntax and the second portion be highlighted using the tcsh syntax. If there doesn't exist one, would it be possible to create a new file type called say multisyn and write a syntax which does the job? Is it possible? Thanks, Krishna Some languages can include text written in other languages, and the corresponding syntax script takes that into account: for instance, you might want to look into $VIMRUNTIME/syntax/html.vim to see how it caters for CSS style sheets, VBS scripts and JS scripts embedded into HTML pages; or into $VIMRUNTIME/syntax/vim.vim which accepts here-documents in perl, python, ruby, tcl or scheme, embedded into Vim scripts. Best regards, Tony.
Re: enable perl
On Tue, 2 Jan 2007, A.J.Mechelynck wrote: see my HowTo page for Unix/Linux: http://users.skynet.be/antoine.mechelynck/vim/compunix.htm See also : help if_perl.txt : help if_cscop.txt Configuring with --enable-perlinterp will (if it succeeds) build a Vim executable with +perl compiled-in, as shown in the ":version" listing. This means that whatever is described in if_perl.txt will work as expected, provided that: (a) the same version of Perl is installed as the one found at compile-time by configure, and (b) Vim can find it at runtime. Thanks. Jorge
Syntax highlighting
Is there a way to have different (see below) syntax highlighting for different portions of a file? What I am interested in knowing is whether there exists a meta file format (say multisyn) which highlights different portions of a file with syntax corresponding to that portion. For instance, let the file multisyn.cat be the following- Start of multisyn.cat +++ #!/usr/bin/perl print "Hello world\n"; foreach $i ( 1 .. 10 ){ print $i,"\n"; } +++ #!/bin/tcsh set hello = "world"; echo $hello +++ End of multisyn.cat What I would like is that each portion of multisyn.cat be highlighted with a different syntax corresponding to that portions file marked by the #!/usr/... indicator. For instance, I would like the first portion to be highlighted using the perl syntax and the second portion be highlighted using the tcsh syntax. If there doesn't exist one, would it be possible to create a new file type called say multisyn and write a syntax which does the job? Is it possible? Thanks, Krishna
Re: automatic code completion in vim
Mikolaj Machowski wrote: On pon sty 1 2007, Mikolaj Machowski wrote: This won't work: you need a different variable name, see ":help E706". Yeah, I forgot (not only about that). This is complete solution:: function! UpdateTags() call writefile(getline(1, '$'), '.tmp.cc', 'b') let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc') " Note: whitespaces around expand are tab chars. let alltags = system('grep -v "'.expand('%').' " tags') let tagstable = split(alltags, '\n') call add(tagstable, tags) call writefile(tagstable, 'tags', 'b') redraw! return ';' endfunction inoremap ; UpdateTags() Note: this is untested in real life, it doesn't return any errors. In good conditions execution of whole function takes 0.46s on big tags file (KMail source, tags size over 4MB, 1 lines). Delay noticeable on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions it was taking up to 0.75s:: FUNCTION UpdateTags() Called 1 time Total time: 0.527128 Self time: 0.401542 count total (s) self (s) 1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b') 1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc') 1 0.91 let stags = split(tags, '\n') 1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' " tags') 1 0.128909 let tagstable = split(alltags, '\n') 1 0.43 call extend(tagstable, stags) 1 0.240341 call writefile(tagstable, 'tags', 'b') 1 0.33 return ';' FUNCTIONS SORTED ON TOTAL TIME count total (s) self (s) function 1 0.527128 0.401542 UpdateTags() FUNCTIONS SORTED ON SELF TIME count total (s) self (s) function 1 0.527128 0.401542 UpdateTags() Note however I've made one fatal mistake. ``ctags fname`` will point to tags in file .tmp.cc not our real current file! Filtering tags in Vim is possible and on small sample quite fast but still 0.5s is long. Maybe we should put that strain to the system:: function! UpdateTags() call writefile(getline(1, '$'), '.tmp.cc', 'b') call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2 tags') let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags') return ';' endfunction inoremap ; UpdateTags() And here we have the winner:: FUNCTION UpdateTags() Called 1 time Total time: 0.145700 Self time: 0.001068 count total (s) self (s) 1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b') 1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2 tags') 1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags') 1 0.29 return ';' FUNCTIONS SORTED ON TOTAL TIME count total (s) self (s) function 1 0.145700 0.001068 UpdateTags() FUNCTIONS SORTED ON SELF TIME count total (s) self (s) function 1 0.145700 0.001068 UpdateTags() Below 0.15s (and even in worse conditions only up to 0.25s)! This is less then one keystroke of good touchtyper. This is for the price of portability but you can find grep/sed/mv for other systems so situation isn't hopeless. HTH m. Thank you for your script. It doesn't work so fast in my computer. There is another problem when I use omnicppcomplete plugin. I don't know if it is its bug. For example, there are two files: tmp1.h class tmp1{ public: void print1(){} }; hello.cc- #include "tmp1.h" class hello{ public: void print(){} static void hello(){} static int h; }; int main(){ hello h; hello::hello(); h. hello::<- the popup menu only appear here tmp1 t1; t1. } I'm sure tags has been created correctly. The popup menu sometimes appears, sometimes doesn't when I type '.' or '->'. I tried many times, but still didn't find the rule: when it appears, when it doesn't. Does anyone meet the similar program? Or has some ideas? Zheng Da
Re: Any way of getting statusline=%B in insert mode?
DervishD wrote: Hi Tony :) :-) Olá Raúl * A.J.Mechelynck <[EMAIL PROTECTED]> dixit: DervishD wrote: I have %B in my status line, but it doesn't work in insert mode, only on normal and visual mode. At first I thought that the status line wasn't being evaluated while in insert mode, but the line and column numbers change correctly, so it *is* being evaluated, it's just that %B doesn't seems to work. I confirm that in Insert/Replace mode %B gives a single digit zero. In Select mode it works OK, even in Select (insert) i.e. when triggered by hitting shift-arrow in Insert mode. OK, thanks for the confirmation. Even in Insert mode, the display is OK in non-current windows (e.g. clicking a status line or using Ctrl-O Ctrl-W w to change windows, gives a correct display on the status line of the window which we just left). So really it is a bug and not a feature. Again, thanks :) IMHO, I said. Bram has the final say, not me. Raúl Núñez de Arenas Coronado Best regards, Tony.
Re: enable perl
Jorge Almeida wrote: Quoting the Makefile: # - Uncomment one or more of these lines to include an interface; # each makes Vim quite a bit bigger: # --enable-perlinterp for Perl interpreter # --enable-pythoninterp for Python interpreter # --enable-rubyinterp for Ruby interpreter # --enable-tclinterp for Tcl interpreter # --enable-cscope for Cscope interface I have no idea what this means. I probably want --enable-perlinterp since I use Perl, but what will it do? And about cscope? What is an interface, in this context? Could someone please elaborate a little on this matter? see my HowTo page for Unix/Linux: http://users.skynet.be/antoine.mechelynck/vim/compunix.htm See also :help if_perl.txt :help if_cscop.txt Configuring with --enable-perlinterp will (if it succeeds) build a Vim executable with +perl compiled-in, as shown in the ":version" listing. This means that whatever is described in if_perl.txt will work as expected, provided that: (a) the same version of Perl is installed as the one found at compile-time by configure, and (b) Vim can find it at runtime. Best regards, Tony.
Re: enable perl
On Tue, 2 Jan 2007, Yakov Lerner wrote: On 1/2/07, Jorge Almeida <[EMAIL PROTECTED]> wrote: Quoting the Makefile: #- Uncomment one or more of these lines to include an interface; # each makes Vim quite a bit bigger: #--enable-perlinterp for Perl interpreter #--enable-pythoninterp for Python interpreter #--enable-rubyinterp for Ruby interpreter #--enable-tclinterp for Tcl interpreter #--enable-cscope for Cscope interface I have no idea what this means. I probably want --enable-perlinterp since I use Perl, but what will it do? This enable the :perl commands (:help :perl) If all you need when editing perl sources is syntax coloring and indentation, then you get it even without --enable-pythoninterp And about cscope? : help if_cscop.txt OK, thank you. -- Jorge Almeida
Re: Any way of getting statusline=%B in insert mode?
Hi Tony :) * A.J.Mechelynck <[EMAIL PROTECTED]> dixit: > DervishD wrote: > >I have %B in my status line, but it doesn't work in insert mode, > >only on normal and visual mode. At first I thought that the status line > >wasn't being evaluated while in insert mode, but the line and column > >numbers change correctly, so it *is* being evaluated, it's just that %B > >doesn't seems to work. > > > I confirm that in Insert/Replace mode %B gives a single digit zero. In > Select mode it works OK, even in Select (insert) i.e. when triggered > by hitting shift-arrow in Insert mode. OK, thanks for the confirmation. > Even in Insert mode, the display is OK in non-current windows (e.g. > clicking a status line or using Ctrl-O Ctrl-W w to change windows, > gives a correct display on the status line of the window which we just > left). So really it is a bug and not a feature. Again, thanks :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen!
Re: enable perl
On 1/2/07, Jorge Almeida <[EMAIL PROTECTED]> wrote: Quoting the Makefile: # - Uncomment one or more of these lines to include an interface; # each makes Vim quite a bit bigger: # --enable-perlinterp for Perl interpreter # --enable-pythoninterp for Python interpreter # --enable-rubyinterp for Ruby interpreter # --enable-tclinterp for Tcl interpreter # --enable-cscope for Cscope interface I have no idea what this means. I probably want --enable-perlinterp since I use Perl, but what will it do? This enable the :perl commands (:help :perl) If all you need when editing perl sources is syntax coloring and indentation, then you get it even without --enable-pythoninterp And about cscope? :help if_cscop.txt Yakov
enable perl
Quoting the Makefile: # - Uncomment one or more of these lines to include an interface; # each makes Vim quite a bit bigger: # --enable-perlinterp for Perl interpreter # --enable-pythoninterp for Python interpreter # --enable-rubyinterp for Ruby interpreter # --enable-tclinterp for Tcl interpreter # --enable-cscope for Cscope interface I have no idea what this means. I probably want --enable-perlinterp since I use Perl, but what will it do? And about cscope? What is an interface, in this context? Could someone please elaborate a little on this matter? -- Jorge Almeida
Re: Any way of getting statusline=%B in insert mode?
DervishD wrote: Hi all, and happy new year! I have %B in my status line, but it doesn't work in insert mode, only on normal and visual mode. At first I thought that the status line wasn't being evaluated while in insert mode, but the line and column numbers change correctly, so it *is* being evaluated, it's just that %B doesn't seems to work. Any way of working around this problem? Is this a feature? Thanks a lot in advance :) Raúl Núñez de Arenas Coronado I confirm that in Insert/Replace mode %B gives a single digit zero. In Select mode it works OK, even in Select (insert) i.e. when triggered by hitting shift-arrow in Insert mode. Even in Insert mode, the display is OK in non-current windows (e.g. clicking a status line or using Ctrl-O Ctrl-W w to change windows, gives a correct display on the status line of the window which we just left). IMHO this is a bug. Best regards, Tony.
Any way of getting statusline=%B in insert mode?
Hi all, and happy new year! I have %B in my status line, but it doesn't work in insert mode, only on normal and visual mode. At first I thought that the status line wasn't being evaluated while in insert mode, but the line and column numbers change correctly, so it *is* being evaluated, it's just that %B doesn't seems to work. Any way of working around this problem? Is this a feature? Thanks a lot in advance :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen!
Re: cvim
spx2 schrieb: just did that and outputted filetype detection:ON plugin:ON indent:ON All these mappings are defined in the file $HOME/.vim/ftplugin/c.vim (filetype plugin). This file must also be loaded. The mappings are only present for c- and h-files (filetype is 'c' or 'cpp') to avoid conflicts with other launguage-specific plugins. If your current buffer is a C/C++-file you should see the mappings with :map (and they should work, of course). Fritz Fritz Mehner wrote: spx2 schrieb: hello. i just installed cvim but \lcs and \ucs work perfectly but \ce or \cn or any other \xx stuff or \xxx stuff don't work at all. what do i do ? Please check if plugins can be loaded: :filetype You should see filetype detection:ON plugin:ON indent:ON If not add a line to file .vimrc : filetype plugin on Fritz
Re: cvim
A.J.Mechelynck schrieb: > spx2 wrote: >> hello. >> i just installed cvim but \lcs and \ucs work perfectly but >> \ce or \cn or any other \xx stuff or \xxx stuff don't work at all. >> what do i do ? > > What is cvim? It's the scrip c.vim: c.vim : C/C++-IDE -- Write and run programs. Insert statements, idioms, comments etc. Further reading on http://www.vim.org/scripts/script.php?script_id=213 Best regards Thomi
Re: cvim
just did that and outputted filetype detection:ON plugin:ON indent:ON Fritz Mehner wrote: > > spx2 schrieb: > >>hello. >>i just installed cvim but \lcs and \ucs work perfectly but >>\ce or \cn or any other \xx stuff or \xxx stuff don't work at all. >>what do i do ? >> >> > Please check if plugins can be loaded: > > :filetype > > You should see > filetype detection:ON plugin:ON indent:ON > > If not add a line to file .vimrc : > filetype plugin on > > Fritz > > -- View this message in context: http://www.nabble.com/cvim-tf2905788.html#a8124063 Sent from the Vim - General mailing list archive at Nabble.com.
Re: perl x modifier regex ?
A.J.Mechelynck a écrit : You can always add one or more lines of comments above or below the line including the pattern in a Vim script, or even, in most cases, at the end of the line; but IIUC you cannot insert comments in the middle of a pattern. Ok. There is no solution so i decided to write functions that returns RE chunks in vimfiles/autoload/RE{,/XML}.vim 2 advantages to proceed like this : - readable. - reusable For Exemple, the way to match an XML tag is almost a FAQ on this list. Why not provide something like the awsome Regexp::Common perl module ? I wrote : function RE#Magic() return '\v' endfunction function RE#Submatch( regExp ) return '('.a:regExp.')' endfunction function RE#OptionnalSubmatch( regExp ) return '(%('.a:regExp.'){0,1})' endfunction function RE#XML#Ident() return '[[:alpha:]][[:alnum:]]*' endfunction function RE#XML#NSIdent() let ident = RE#XML#Ident() " a namespace " : separator " a tagname return \ RE#OptionnalSubmatch( ident ) . \ RE#OptionnalSubmatch( ':' ) . \ RE#OptionnalSubmatch( ident ) . endfunction Comments and advices about it would be really nice. To use perl regexps, you can of course embed perl statements in a perl-enabled version of Vim; but of course at the cost of making the script less portable. I gave this solution away a long time ago. I think that all alien langages (langages other than viml) is the worst idea of the vim developper team. regards mc
RE: Bug in 7.0.178? autocmd BufReadCmd * DoSomething expand("") fails if the filename contains %
>> Shouldn't be wrapped in escape before the expand, >> so that -- omitting other arguments -- the sequence would be: >> >> expand( escape( ) ) >> > I'd assumed that "" is an argument to expand (:h > expand()) and only valid in this context. OK -- I put the cursor on common%h and executed the command :echo escape(expand(""), "%") The result was: common\%h Also, escaping a second time with :echo escape(escape(expand(""), "%"), "%") resulted in common\\%h --Suresh
Re: perl x modifier regex ?
Hi Theerasak, my problem is not to read the regExp but maintain them so your script don't help here. It sounds good btw. Regards, mc Theerasak Photha a écrit : On 12/28/06, Marc Chantreux <[EMAIL PROTECTED]> wrote: hi all, Is there a way to obtain the perl x modifier behaviour in vim regex (spaces are non significants, comments are allowed). This is very usefull to make a regexp more readable. No, but there is this: http://www.vim.org/scripts/script.php?script_id=1091
surrparen
Hi, Now I'm writing a plugin that hilights a pair of parens/braces which surround the cursor position. Unlike matchparen.vim, it works even when the cursor is not just on a paren/brace. The attached file is the source. But I have noticed a bothering problem with it. When cursor is on '0' in the following text, | v do_all = (flags[0] == 'g'); do_all = (flags[1] == 'g'); you press jj, then the cursor normally should down two lines and on '1'. But when using this plugin, it goes the first column. I'm wondering how I can avoid this problem. Any ideas? and any other suggestion is welcome. Regards, -- AOYAMA Shotaro mailto:[EMAIL PROTECTED] surrparen.vim Description: Binary data
RE: Bug in 7.0.178? autocmd BufReadCmd * DoSomething expand("") fails if the filename contains %
Thomas sent to vim-dev@vim.org > I have the following line in my source: > > exec 'autocmd BufReadCmd '. pattern .' call '. rcmd .'(1, > expand(""), "", "%")' > > This fails if the filename contains % which is replaced with > expand('%'). I can't seem to escape the % at any point, can I? > Wrapping the exand("") in a escape(<>, "%") doesn't help. Shouldn't be wrapped in escape before the expand, so that -- omitting other arguments -- the sequence would be: expand( escape( ) ) --Suresh