Re: yank entire function when on functionname
On 03/11/2011 05:06 AM, KF wrote: On Mar 10, 5:35 pm, Jeroen Budtsjer...@lightyear.be wrote: Hi, I'm looking for the quickest method to yank an entire (php) function when the cursor is somewhere in the first line of the function definition like this (| = cursor): fun|ction foobar() { if (true) { return not false :); } } One possible solution would be: jvaBVy But I'm wondering if there it is possible in a shorter way and maybe without using visual mode. Another solution I found is: v][Vy But this only seems to work if the function itself is not indented and when i tried it without visual mode (^y][) it didn't include the last line (}). You can redefine the ][ meaning: [ :help section ] :map ][ /}CRb99]} and using your sequence, should work quite well: v][Vy It seems that only way to go is using visual mode... I tried this mapping but it doesn't seem to work for me when i try this in a PHP class (functions are indented by 4 spaces). It jumps always to the last } in the file, which is the } to close the class definition. But while I was looking up the help on ][ (:help ][) and read about ]] as well and I noticed that this also only looks for the } on the first column. However, I have been using the ]] command successfully in PHP files to jump from function to function when functions are indented (because they are part of a class). So this made me realize that the ]] command was already remapped somewhere. After searching a bit (with :verbose map ]]?) I discovered that the ftplugin for php (/usr/share/vim/vim73/ftplugin/php.vim in my case) remaps the ]] and [[ commands (line 69) to be 'php-aware'. Sadly it does not remap the ][ and [] to be as intelligent as well. So now I'm wondering, shouldn't the php ftplugin be modified to also remap the ][ and [] commands so they have a more consistent and to-be-expected behavior? And would it be possible to come create a working mapping? I guess something like 'search back for the nearest class/function/interface definition, calculate the indent of that line, and search for the first } with the same indent' could work (but only if the php code is correctly indented)? Jeroen -- website: http://budts.be/ - twitter: @teranex ___ Registered Linux User #482240 - GetFirefox.com - ubuntu.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
Normal mode commands when Caps Lock is on
Hello, Is it possible to reverse uppercase letter and lowercase letter when Caps Lock is on? Sometimes normal mode commands are uncomfortable to use when Caps Lock is on. When Caps Lock is on, For example, Shift + I would lead to the effect of 'i', which makes me very uncomfortable. Thanks. Regards, H Xu 03/11/2011 -- 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: MozRepl + vim
Now I found one more problem. It happened three times already, when I :write, Vim just hangs and there is nothing else I can do unless to kill Vim's process. Also, when this happens, CPU usage goes from 50% to 95%. I tried waiting a long time before killing Vim's process to see if it would eventually go back to normal by itself but that never happened. I installed the version that seems to be the stable version of mozrepl fro this link: https://github.com/bard/mozrepl/wiki (MozRepl 1.0 – release). netcat --version netcat (The GNU Netcat) 0.7.1 vim --version VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 19 2011 18:42:05) Included patches: 1-125 Compiled by ArchLinux Do you guys think it might be the code snippet pasted into vim that is causing that? -- 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: yank entire function when on functionname
On 03/11/2011 09:55 AM, Jeroen Budts wrote: On 03/11/2011 05:06 AM, KF wrote: On Mar 10, 5:35 pm, Jeroen Budtsjer...@lightyear.be wrote: Hi, I'm looking for the quickest method to yank an entire (php) function when the cursor is somewhere in the first line of the function definition like this (| = cursor): fun|ction foobar() { if (true) { return not false :); } } One possible solution would be: jvaBVy But I'm wondering if there it is possible in a shorter way and maybe without using visual mode. Another solution I found is: v][Vy But this only seems to work if the function itself is not indented and when i tried it without visual mode (^y][) it didn't include the last line (}). You can redefine the ][ meaning: [ :help section ] :map ][ /}CRb99]} and using your sequence, should work quite well: v][Vy It seems that only way to go is using visual mode... I tried this mapping but it doesn't seem to work for me when i try this in a PHP class (functions are indented by 4 spaces). It jumps always to the last } in the file, which is the } to close the class definition. But while I was looking up the help on ][ (:help ][) and read about ]] as well and I noticed that this also only looks for the } on the first column. However, I have been using the ]] command successfully in PHP files to jump from function to function when functions are indented (because they are part of a class). So this made me realize that the ]] command was already remapped somewhere. After searching a bit (with :verbose map ]]?) I discovered that the ftplugin for php (/usr/share/vim/vim73/ftplugin/php.vim in my case) remaps the ]] and [[ commands (line 69) to be 'php-aware'. Sadly it does not remap the ][ and [] to be as intelligent as well. So now I'm wondering, shouldn't the php ftplugin be modified to also remap the ][ and [] commands so they have a more consistent and to-be-expected behavior? And would it be possible to come create a working mapping? I guess something like 'search back for the nearest class/function/interface definition, calculate the indent of that line, and search for the first } with the same indent' could work (but only if the php code is correctly indented)? After reading some more vim documentation I discovered the [M command. According to the documentation this is specific for Java code, but since PHP classes are very similar in code to java, it works for PHP as well. Sadly this only works for PHP methods which are defined in a class. For functions which are not in a class [M jumps to the opening { of the function, but 2[M correctly jumps to the end. So maybe the php ftplugin could be modified to redefine ][ to check whether the cursor is inside a class and, if so, call [M, if not call 2[M? Jeroen -- website: http://budts.be/ - twitter: @teranex ___ Registered Linux User #482240 - GetFirefox.com - ubuntu.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
include file search problems (implicit and multiple includes)
I am somewhat fond of Vim's include and definition search and would like to spread their use to non-C-like languages, but I find the identification by prefix patterns too limiting for some of the languages I use. Perhaps someone here can help? For 'define', I can work around the limitiations of prefix matching because include file search itself is exposed as a command, so I can build my own scripts. For 'include', I haven't been able to find a workaround: is there any way to add include files by Vim script? Two examples of the kind of problems I'd like to solve can be illustrated with Javascript projects: (a) there are implicit include files, which I'd like to add (e.g., if multiple .js files are included from some index.html file, I'd like to include the index.html from every .js file, so that the include from the HTML allows discovery of the other relevant .js files) (b) module import constructs are too complex to extract individual imports by prefix match only (instead, I'd like to identify the module construct, and extract a list of include files by script) One sufficient solution to (a) would be if I could use \zs\%1l\ze in 'include', to get a single guaranteed match in the file, and 'includeexpr', to convert the contents of the match into 'index.html'. By my reading of the docs that should be possible, but I can't get it to work. One sufficient solution to (b) would be if 'includeexpr' could optionally return a list of include files. Any suggestions? Claus -- 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: yank entire function when on functionname
Jeroen Budts wrote: Hi, I'm looking for the quickest method to yank an entire (php) function when the cursor is somewhere in the first line of the function definition like this (| = cursor): fun|ction foobar() { if (true) { return not false :); } } [snip] If you use syntax folding... (put into ~/.vim/ftplugin/php.vim) let php_folding= 1 set fdm=syntax then a simple Y with the cursor atop a folded function will yank it. Regards, Chip Campbell -- 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: Normal mode commands when Caps Lock is on
On 03/11/2011 04:26 AM, H Xu wrote: Is it possible to reverse uppercase letter and lowercase letter when Caps Lock is on? Sometimes normal mode commands are uncomfortable to use when Caps Lock is on. When Caps Lock is on, For example, Shift + I would lead to the effect of 'i', which makes me very uncomfortable. To make this useful, I suspect Vim would have to be able to detect when Caps Lock is toggled on vs. off. As far as I know, there's no way to do this short of OS keyboard-remapping so that it sends something other than Caps that Vim can detect the keypress. That said, unless you have some pressing need to use caps-lock, I tend to disable it (or rather, I make it my Compose key on X). Additionally, unless you're using Caps outside of Vim, I'd not bother using Caps at all within Vim given the ease with which textual transformations can be performed (:help gU). As a final resort if your text requires all caps all the time, (such as FORTRAN, IIUC) you might do a bunch of mappings like :inoremap a A :inoremap b B ... :inoremap z Z -tim the Caps-lock hater :) -- 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: Normal mode commands when Caps Lock is on
On Fri, 11 Mar 2011, H Xu wrote: Hello, Is it possible to reverse uppercase letter and lowercase letter when Caps Lock is on? Sometimes normal mode commands are uncomfortable to use when Caps Lock is on. When Caps Lock is on, For example, Shift + I would lead to the effect of 'i', which makes me very uncomfortable. Instead of using CapsLock, you can use this keymap that I just uploaded: http://benizi.com/vim/swapcaps.vim It's UTF-8-encoded... (will fix that in the hosting config later). To install, put it in ~/.vim/keymap/swapcaps.vim Then to use: :set keymap=swapcaps There are probably other methods to make using it more convenient, but setting the 'keymap' option should get you started. The keymap applies only in insert mode, so solves the original problem you're having. -- Best, Ben -- 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: MozRepl + vim
On Thu, March 10, 2011 5:38 pm, Benjamin R. Haskell wrote: match WhiteSpaceError /[\x0b\x0c\u00a0\u1680\u180e\u2000-\u200a\u2028\u202f\u205f\u3000]/ Also adding Zero-Width No-Breaking space (a.k.a. BOM) (might not want to add this if you use any variant of UTF-16 on a regular basis): match WhiteSpaceError /[\x0b\x0c\u00a0\u1680\u180e\u2000-\u200a\u2028\u202f\u205f\u3000\ufeff]/ Nice, thanks for sharing. 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: yank entire function when on functionname
On 03/11/2011 05:02 PM, Charles Campbell wrote: Jeroen Budts wrote: Hi, I'm looking for the quickest method to yank an entire (php) function when the cursor is somewhere in the first line of the function definition like this (| = cursor): fun|ction foobar() { if (true) { return not false :); } } [snip] If you use syntax folding... (put into ~/.vim/ftplugin/php.vim) let php_folding= 1 set fdm=syntax then a simple Y with the cursor atop a folded function will yank it. Normally I don't use folding, because I don't really like it (i set nofoldenable in my vimrc), but this is a nice case of when it can be useful as this does indeed do exactly what i was looking for! Thx! Jeroen -- website: http://budts.be/ - twitter: @teranex ___ Registered Linux User #482240 - GetFirefox.com - ubuntu.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: yank entire function when on functionname
On Friday 11 March 2011 13:42:55 Jeroen Budts wrote: Normally I don't use folding, because I don't really like it (i set nofoldenable in my vimrc), but this is a nice case of when it can be useful as this does indeed do exactly what i was looking for! i seldom use folds but when i encounter them i make use of a mapping i think i got from Charles -- it's a fold toggle: nnoremap silent space :exe 'silent! normal! '. ((foldclosed('.')0)? 'zMzx' : 'zc')cr should be all one line if your mail client wrapped it, and you can use anything if you don't want to use space for this 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
Yank to + also yanks to * when suppressing a in guioptions in unix
Hello, Using gvim in unix, a is by default in guioptions. Yanking a word to the Unix clipboard (with +yw) does not yank the word to the Selection buffer (*). When suppressing the a option (with set guioptions-=a), yanking a word to the Unix clipboard (with +yw) also yanks the word to the Selection buffer (*). Is there a reason for this behaviour or is it a bug ? Best regards, Jean Johner -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
How to use color to search
Hi, All I am new to vim. Part of my job is to search a lot of key word from very large LOG files. I am sure I can use vim do it but do not know how. What I need to do is have some list of keyword group (keyword that have special chararters eg / . ? [ ])and use VIM to mark to different color. I worked for servial hours still can't get it work. Anybody can help? Thanks James -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
RE: How to use color to search
lucentjames wrote: What I need to do is have some list of keyword group (keyword that have special chararters eg / . ? [ ])and use VIM to mark to different color. Syntax rules can be used, or highlighting with matchad(). One approach would be to use this tip (it uses matchadd()): http://vim.wikia.com/wiki/Highlight_multiple_words Use :Hsample to show a sample of the hightlights, which you can change by editing the supplied highlights.csv file. Assuming you want the same highlights over several sessions, you could put commands like these in a file (say my.vim): Hi 7 alpha Hi 8 beta Hi 9 gamma.delta In Vim, use this command to source (apply) the commands: :so my.vim The '.' in 'gamma.delta' matches any character. It's an easy way of highlighting 'gamma delta' (with a space). Hmmm, looking at the tip I see that I had forgotten about :Hsave and :Hrestore which would be another way to save settings. John -- 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: Normal mode commands when Caps Lock is on
On 2011/3/12 2:45, Benjamin R. Haskell wrote: On Fri, 11 Mar 2011, H Xu wrote: Hello, Is it possible to reverse uppercase letter and lowercase letter when Caps Lock is on? Sometimes normal mode commands are uncomfortable to use when Caps Lock is on. When Caps Lock is on, For example, Shift + I would lead to the effect of 'i', which makes me very uncomfortable. Instead of using CapsLock, you can use this keymap that I just uploaded: http://benizi.com/vim/swapcaps.vim It's UTF-8-encoded... (will fix that in the hosting config later). To install, put it in ~/.vim/keymap/swapcaps.vim Then to use: :set keymap=swapcaps There are probably other methods to make using it more convenient, but setting the 'keymap' option should get you started. The keymap applies only in insert mode, so solves the original problem you're having. This works fine for me. Thanks. -- 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: Normal mode commands when Caps Lock is on
On 2011/3/12 0:32, Tim Chase wrote: To make this useful, I suspect Vim would have to be able to detect when Caps Lock is toggled on vs. off. As far as I know, there's no way to do this short of OS keyboard-remapping so that it sends something other than Caps that Vim can detect the keypress. That said, unless you have some pressing need to use caps-lock, I tend to disable it (or rather, I make it my Compose key on X). Additionally, unless you're using Caps outside of Vim, I'd not bother using Caps at all within Vim given the ease with which textual transformations can be performed (:help gU). As a final resort if your text requires all caps all the time, (such as FORTRAN, IIUC) you might do a bunch of mappings like :inoremap a A :inoremap b B ... :inoremap z Z -tim the Caps-lock hater :) Those inoremaps makes input uncomfortable, but thanks anyway. -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
how to keep one window's width the same all the time
Hi, I want to keep one of my window (file explorer) the same width all the time (now, it's always resized if I quite one window). One way to do this could run a resize command on the file explorer buffer all the time. But, I didn't find a way to run a command on a specific buffer/window. Could you help me on this? -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
how to keep the window width the same all the time
Hi, I want to keep one of my window (file explorer) the same width all the time (now, it's always resized if I quite one window). One way to do this could run a resize command on the file explorer buffer all the time. But, I didn't find a way to run a command on a specific buffer/window. Could you help me on this? Thanks! Wei -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: how to keep one window's width the same all the time
On 12/03/11 07:23, wei gao wrote: Hi, I want to keep one of my window (file explorer) the same width all the time (now, it's always resized if I quite one window). One way to do this could run a resize command on the file explorer buffer all the time. But, I didn't find a way to run a command on a specific buffer/window. Could you help me on this? - see :help 'winfixwidth' - The first message by any user is moderated, which means that a moderator has to notice it, see that it isn't spam, and then approve that user for unmoderated posting. That can take more than the 8 minutes you waited, especially when all moderators are asleep (there is no round-the-clock watch). - Happy Vimming! Best regards, Tony. -- The Right Honorable Gentleman is indebted to his memory for his jests and to his imagination for his facts. -- Sheridan -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: How to use color to search
On 03/12/2011 03:32 AM, John Beckett wrote: lucentjames wrote: What I need to do is have some list of keyword group (keyword that have special chararters eg / . ? [ ])and use VIM to mark to different color. Syntax rules can be used, or highlighting with matchad(). One approach would be to use this tip (it uses matchadd()): http://vim.wikia.com/wiki/Highlight_multiple_words Use :Hsample to show a sample of the hightlights, which you can change by editing the supplied highlights.csv file. Assuming you want the same highlights over several sessions, you could put commands like these in a file (say my.vim): Hi 7 alpha Hi 8 beta Hi 9 gamma.delta In Vim, use this command to source (apply) the commands: :so my.vim The '.' in 'gamma.delta' matches any character. It's an easy way of highlighting 'gamma delta' (with a space). Hmmm, looking at the tip I see that I had forgotten about :Hsave and :Hrestore which would be another way to save settings. There is also the Mark-script (http://www.vim.org/scripts/script.php?script_id=2666), which let's you add highlights on-the-fly. You can then also jump from mark to mark (with Leader* and Leader/). Jeroen -- website: http://budts.be/ - twitter: @teranex ___ Registered Linux User #482240 - GetFirefox.com - ubuntu.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: how to keep one window's width the same all the time
On 12/03/11 08:27, wei gao wrote: Hi, It works. Thanks a lot:) And I and one autocmd to avoid setting this everytime I reopen the file explorer window: autocmd BufEnter \[File?List\] exec 'set winfixwidth' I recommend :setlocal winfixwidth (rather than just plain :set), otherwise *all* new split-windows opened from then on would (IIUC) get wfw set to TRUE, because (except for purely global options) :setlocal sets only the local value :setglobal sets only the global default :set sets both Also, if it's the only command in your autocommand, you don't need :exec; and setting it again every time you re-enter the buffer (even by Ctrl-W w or by mouse-clicking) is wasteful. I don't use the file explorer myself, but I think that something like :au BufWinEnter \[File\ List\] setlocal wfw or similar, ought to be enough. Best regards, Tony. -- Reintegration complete, ZORAC advised. We're back in the universe again ... An unusually long pause followed, ... but I don't know which part. We seem to have changed our position in space. A spherical display in the middle of the floor illuminated to show the starfield surrounding the ship. Several large, artificial constructions are approaching us, ZORAC announced after a short pause. The designs are not familiar, but they are obviously the products of intelligence. Implications: we have been intercepted deliberately by a means unknown, for a purpose unknown, and transferred to a place unknown by a form of intelligence unknown. Apart from the unknowns, everything is obvious. -- James P. Hogan, Giants Star -- 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