Re: Can 'set ' be elided? When?
On Sat, Mar 23, 2013 at 12:58 AM, Paul Isambert zappathus...@free.fr wrote: I notice that some settings use the format ':set name=value' and other use ':name value'. For instance: :set syntax=php :syntax off Note that :syntax php doesn't work. Can the string 'set ' always be safely elided? No. If not, then what are the guidelines? As far as I can tell, there aren't any. Some commands have the same name as options (e.g. :filetype and 'filetype', :confirm and 'confirm'), but they don't do the same things. Best, Paul I notice that the following doesn't work: :syntax php However the following does work: :colorscheme desert Why is syntax an option yet colorscheme a command? -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 --- You received this message because you are subscribed to the Google Groups vim_use group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Can 'set ' be elided? When?
On Sun, Mar 31, 2013 at 7:34 PM, Christian Brabandt cbli...@256bit.org wrote: Why is syntax an option yet colorscheme a command? Probably because colorschemes do not change the behaviour of Vim but rather change its appearance. But who really knows the reasoning why some commands are not options? Thank you. I did not realize that syntax actually changes the behaviour of VIM. I suppose that it could change things like indentation. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 --- You received this message because you are subscribed to the Google Groups vim_use group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Can 'set ' be elided? When?
On Sat, Mar 23, 2013 at 12:58 AM, Paul Isambert zappathus...@free.fr wrote: Selon Dotan Cohen dotanco...@gmail.com: I notice that some settings use the format ':set name=value' and other use ':name value'. For instance: :set syntax=php :syntax off Note that :syntax php doesn't work. Can the string 'set ' always be safely elided? No. If not, then what are the guidelines? As far as I can tell, there aren't any. Some commands have the same name as options (e.g. :filetype and 'filetype', :confirm and 'confirm'), but they don't do the same things. Best, Paul Thank you, I did not realize the difference between commands and options, as some of them have the same names: :set syntax=php is setting an option (_which_ syntax to use) :syntax off is running a command (_do_ enable syntax highlighting) Paying attention to 'which' or 'do' is helping me sort this out. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 --- You received this message because you are subscribed to the Google Groups vim_use group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Can 'set ' be elided? When?
I notice that some settings use the format ':set name=value' and other use ':name value'. For instance: :set syntax=php :syntax off Can the string 'set ' always be safely elided? If not, then what are the guidelines? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 --- You received this message because you are subscribed to the Google Groups vim_use group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to solve Bidi support in Vim/GVim
On Tue, Nov 13, 2012 at 3:29 AM, Tony Mechelynck antoine.mechely...@gmail.com wrote: But I think doing it well would be a whole can of worms. I'm not sure it is possible to do it correctly in all cases, including those where part or all of the directionality is defined in a file external to the one being edited (e.g.in a style sheet for HTML or similar). It might require a complete overhaul of not only ordinary display but also syntax highlighting, since how to handle span dir=rtl…/span in HTML might be better defined in an HTML syntax script than in the core display routines… Not to mention more complicated (recursive) embeddings such as p dir=ltrenglish1 span dir=rtlfarsi2 span dir=ltrenglish3 span dir=rtlfarsi4/span english5/span farsi6/span english7/p (I ought to have shown it with mixed Arabic and Latin script but I'm lazy) which will have to be displayed (if on a single screen line!) as english1 6israf english3 4israf english5 2israf english7 (IYSWIM) because the underlying structure (English text quoting a Farsi phrase which itself quotes an English phrase which etc.) is p → → → → → → → → → → → → → → → → → → → → → → → → /p /span ← ← ← ← ← ← ← ← ← ← ← ← span span → → → → → /span ←span Then if soft-wrapping (due to narrow window width and 'wrap' on) happens in the middle of the farsi4 span, we get: [english1 english3 {raf 2israf 6israf 4is] english5 english7} where [ or ] is the start of the screen line and { or } its end. Not obvious, is it? Though I cannot code it, I would be very happy to help with the implementation details. To be honest, Mozilla applications have this down pat, and that could be used as a reference for cursor behaviour. In any case, see this page (disclaimer: my own website) explaining how RTL and LTR spans work together: http://dotancohen.com/howto/rtl_right_to_left.html -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 solve Bidi support in Vim/GVim
The mlterm terminal can do that, and it will happily display Hebrew and Arabic (but not Arabic-Hindic digits) RTL and Latin, Cyrillic, Chinese, etc. (including Arabic-Hindic digits) LTR, even on the same line. The Hindu numerals are LTR, just like the Arabic numerals that westerners are familiar with. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Thu, Nov 1, 2012 at 9:09 AM, Tony Mechelynck antoine.mechely...@gmail.com wrote: In Vimscript, an interpreted language, there are no declarations: any command needs to be executed in order to have an effect. It is when flow control goes through the :au, :map, :abbrev, :function or :command command, for instance, that the autocommand, mapping, abbreviation, function definition or user-command definition are stored in interpreter memory; before that, Vim doesn't know anything about them. Similarly, the type of a variable is set by the latest :let command affecting that variable, you cannot declare a variable except by giving that variable a value (possibly an empty value such as , [] or {}). I realize that. I just stated that Vimscript is different than other environments that I am familiar with, and that it was good of you to point out an important difference. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Wed, Oct 31, 2012 at 12:55 PM, Tony Mechelynck antoine.mechely...@gmail.com wrote: Yes, and in addition, if you don't use a scope prefix Vim implies l: if you're inside a function and g: otherwise. See :help internal-variables Thank you, that is not consistent with other programming environments that I am familiar with. Very good to know! Question: Man Invented Alcohol, God Invented Grass. Who do you trust? I'm pretty sure that God invented alcohol too, actually. I know that I've had pomegranate juice ferment into a type of wine just sitting there in the container. Divine fermentation? -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Wed, Oct 31, 2012 at 8:33 PM, Tim Chase v...@tim.thechases.com wrote: On 10/31/12 06:05, Dotan Cohen wrote: On Wed, Oct 31, 2012 at 12:55 PM, Tony Mechelynck wrote: Yes, and in addition, if you don't use a scope prefix Vim implies l: if you're inside a function and g: otherwise. See :help internal-variables Thank you, that is not consistent with other programming environments that I am familiar with. Very good to know! Python happens to work this way: x = 42 def foo(): x = 32 return x print foo() print x prints 32 followed by 42 (the x remains local to the function). Right, this is how most C-based languages work. I don't know if Python is C-based (I think so), but this is what I expect. What I don't expect is that x would be recognized inside the foo() declaration if it was only defined outside, as Tony mentions is the case with VIM. Let's try: x = 42 print x 42 def foo(): ... print x ... print x 42 foo() 42 Wow! This would be at minimum a compiler warning at at worse a huge security flaw in other languages. I happen to have PHP handy: php $x = 42; php echo $x . PHP_EOL; 42 php function foo() { php { echo $x . PHP_EOL; php { return true; php { } php echo $x . PHP_EOL; 42 php foo(); PHP Notice: Undefined variable: x in php shell code on line 2 The variable $x was not declared in foo(), and is not valid there. Now, to check my suspicions: - neptune:c$ cat scopeTest.c #include stdio.h int foo(); int main() { int x = 42; printf(%d, x); foo(); return 0; } int foo() { printf(%d, x); } - neptune:c$ gcc scopeTest.c scopeTest.c: In function ‘foo’: scopeTest.c:15:15: error: ‘x’ undeclared (first use in this function) scopeTest.c:15:15: note: each undeclared identifier is reported only once for each function it appears in - neptune:c$ Nope, C won't allow it either. In both PHP and C there are ways to explicitly make x global, but it is not implicit. I've noticed little bits of Python show up in VimScript--such as array slicing, negative-indexing, and first-class(ish) functions. Not that I mind, as Python is my preferred language. :-) There may be others where this scope is the same (pascal comes to mind) I've actually never touched Pascal, nor Cobol or Fortran for that matter. Thank you for the information regarding Python. I do dabble in Python occasionally, and things like this I should know. I love Python, but VIM is ill-equipped to handle bracketless languages out of the box! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Wed, Oct 31, 2012 at 9:52 PM, donothing successfully donothingsuccessfu...@gmail.com wrote: On 31 October 2012 19:15, Dotan Cohen dotanco...@gmail.com wrote: […] #include stdio.h int foo(); int main() { int x = 42; printf(%d, x); foo(); return 0; } int foo() { printf(%d, x); } […] Here x is a local variable of the function *main*. I think the global keyword is more of a weirdism of PHP than standard practise. http://en.wikipedia.org/wiki/Global_variable#C_and_C.2B.2B Exactly. However, there is no flow control outside of main(), so I don't account for variables declared outside of main(). If someone is declaring a variable in an area of the program with no flow control, then they are explicitly declaring their intentions that the variable will be global. In other words, it is not a surprise or a gotcha when the variable is available in a different scope. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
What do I need to read to understand g: and s: VIM variable prefixes?
What do I need to read to understand g: and s: VIM variable prefixes? This one is hard to guess for the built in help, and Google isn't helping. The root of the issue is trying to figure out why g:someVariable can be seen in SomeFunction() but cannot be seen in s:AnotherFunction(). What is the s: for that precedes the second function's name, and why does it change scope (s for scope, perhaps)? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Tue, Oct 30, 2012 at 8:09 PM, hermi...@free.fr wrote: Hello, What do I need to read to understand g: and s: VIM variable prefixes? This one is hard to guess for the built in help, and Google isn't helping. Have you tried :h s:^D ? which will give you :h s:var I had no idea that ^D would complete in :h! That's it, I'll never have to post to the list again! :) The root of the issue is trying to figure out why g:someVariable can be seen in SomeFunction() but cannot be seen in s:AnotherFunction(). someVariable in a function will be actually l:someVariable. When accessing global variables from functions, always prefix them with g:. What is the s: for that precedes the second function's name, and why does it change scope (s for scope, perhaps)? Thanks. s: stands for script. The scope of the variable is the script. As file static variables in C. Thanks. Actually, since my first post I see that I did have a bug in the function: reducing it to a most-simple case revealed the flaw. In any case, what I have is a function in .vimrc that begins with s:, something that was suggested to me on SuperUser, so I'd like to know what it's doing, not just how to do it. Thank you. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What do I need to read to understand g: and s: VIM variable prefixes?
On Tue, Oct 30, 2012 at 9:27 PM, Ben Fritz fritzophre...@gmail.com wrote: Any of the [gvslawtb]: prefixed variables define the scope of the variable, as follows: g: global variable, accessible anywhere v: special variable predefined by Vim only useful in certain contexts, see the help entry for that variable s: script-local variable, accessible anywhere within a given script file l: function-local variable, only accessible with the defining function a: function argument w: window-local variable, global variable but with a separate copy for every single window t: tab-local variable, global variable but with a separate copy for each tab page b: buffer-local variable, global variable but with a separate copy for each buffer Great, thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Replacing current line with last-yanked register
On Tue, Oct 16, 2012 at 2:48 PM, ping songpingem...@gmail.com wrote: this is a really nice tip , even if sound simple, vim-golf best practice so far I heard. I'll start re-train my finger on this... not sure we have a place to maintain these best-practice stuffs that people spend time to work out? There is the VIM-tips wiki, but that is more formatted for large, complex tips. If you know any handy one-liners, send them to me. I have a few tens of VIM one-liners and short tips like this that I will put on dotancohen.com when I move it over to a new server (already provisioned). There is no advertising on that site, just some helpful tips for and by the community. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Replacing current line with last-yanked register
On Tue, Oct 16, 2012 at 7:11 PM, Christian Brabandt cbli...@256bit.org wrote: I guess, there would nothing be wrong with creating a One-Liners Page for Vim at the wiki similar to the sed-1-liners.txt that is floating around the net. That would make sense too. I just looked through the FAQ and a few other pages, there seems to be no restriction about including multiple tips on one page. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Replacing current line with last-yanked register
On Mon, Oct 15, 2012 at 2:40 PM, Cesar Romani cesar.rom...@gmail.com wrote: In tha case you could use S instead of C, then CTRL-R0 and ESC. Then you only need to use '.' Thanks, Cesar, that ties up the last missing piece of this puzzle! Terrific! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Replacing current line with last-yanked register
On Sun, Oct 14, 2012 at 1:54 PM, Marcin Szamotulski msza...@gmail.com wrote: If you yanked the line then it is still in the 0 register. You can paste from it. Though this will be four keystrokes: V0p If you do that often you could use a map: vnoremap P 0p and then there are only two keystrokes: VP Best, Marcin Thank you Marcin. I don't want to create a map as I've already got every short combination that is mappable mapped and used often! `V0p` would be a good solution if it were repeatable with the period character. Is there any solution which is repeatable by the period character? I tried `IC-oVp` with the hope that the `i` would make it repeatable, but this is not so! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Replacing current line with last-yanked register
On Sun, Oct 14, 2012 at 3:30 PM, Marcin Szamotulski msza...@gmail.com wrote: Yes there is one, you could use C at the beginning of a line, but you have to yank the line with y$ rather than Y (to not catch the EOL) Explicitly you can use this: press C, now you are in the insert mode, and press ^r0 (i.e. CTRL-R0) and ESC. The `-` might also be helpful, it jumps to the beginning of the previous line. Great, Marcin, thank you! I must do `0.` for each line but that is fine. This is quite why I love VIM and don't even consider any other text editor even with all my contemporaries on IDEs. I _felt_ that there had to be a simple way to do this task in VIM. That's just VIM. Thank you Marcin for showing me the bits of VIM that I was missing. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Change colour of cursor and matching bracket
On Sun, Sep 30, 2012 at 11:20 PM, Ben Fritz fritzophre...@gmail.com wrote: On Sunday, September 30, 2012 4:12:21 AM UTC-5, dotancohen wrote: Where in the fine manual is it mentioned how to change the colour of the cursor and the colour of the matching parenthesis / bracket for all file types? :he hl-Cursor :he hl-MatchParen Thank you, but that just leads to a link to Syntax highlighting. Ostensibly this is what I want, but on my system (Kubuntu with VIM 7.3 running in Konsole, and also tried SSHing into CentOS with VIM 7.2 from the same Konsole) configuration such as the following do not change the matched parenthesis: highlight MatchParen cterm=bold ctermfg=red ctermbg=blue I have tried :h cursor color and several other phrases, the only relevant one that I found it h color which did not lead me to the answer. I have tried highlight MatchParen cterm=bold ctermfg=red ctermbg=blue but this did not change the colour of the matching parenthesis or bracket. This should have worked, assuming you're using Vim in a terminal and not gvim. For gvim you'd need guifg and guibg highlights. See :help :highlight, :help highlight-args, and the following text for details on the command. Yes, this was in VIM, not GVIM. It seems that no matter what I define in .vimrc, VIM still uses the reverse colours of the item (swap background and foreground) for the cursor You don't mention specifically what you tried, but the default cursor highlight (at least for my gvim install on Lubuntu) is guibg=fg guifg=bg, which would indeed reverse the color, so this makes sense if nothing you tried actually was correct. So what DID you try, if you can't get it working with a hi Cursor ... command? and a cyan background for the matching parenthesis / bracket. You used ctermfg and ctermbg, so I'll assume you're using a terminal (and a color one at that). Do the numbers (instead of the names) in :help cterm-colors work any better? No, unfortunately the numbers did not work either. I'll start playing around with clean .vimrc and .vim/ to see if something in there is interfering. What does :verbose hi Cursor and :verbose hi MatchParen show you? Perhaps the :hi command in your .vimrc is being overwritten later by a colorscheme command or something. Do :hi commands for other items work? Do you get colorful and customizable syntax highlighting, for example? Yes, syntax highlighting works in all languages that I have tried. Perhaps your terminal is misconfigured so that Vim doesn't realize it's a color terminal. I won't be much help in that regard, but I know you can cheat within Vim by setting t_Co and some other terminal codes. Do a :helpgrep t_Co and browse the list of hits for details. Or search the wiki: http://vim.wikia.com/wiki/index.php?search=t_Cofulltext=Search Thanks, I'll get on that! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Change colour of cursor and matching bracket
Where in the fine manual is it mentioned how to change the colour of the cursor and the colour of the matching parenthesis / bracket for all file types? I have tried :h cursor color and several other phrases, the only relevant one that I found it h color which did not lead me to the answer. I have tried highlight MatchParen cterm=bold ctermfg=red ctermbg=blue but this did not change the colour of the matching parenthesis or bracket. It seems that no matter what I define in .vimrc, VIM still uses the reverse colours of the item (swap background and foreground) for the cursor, and a cyan background for the matching parenthesis / bracket. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Create a 1,000,000 byte file with VIM.
I am trying to create a 1,000,000 byte file with VIM. The following has VIM using 100% of _both_ my CPUs (Intel DuoCore) for almost two hours before I killed it: iaesc100. /i assume that the holdup is not that 100 'a' characters are being written, but rather that insert mode is being inserted and left 100 times. Is there a better way, other than just doing the operation 1000 times, then copying that another 1000 times? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Create a 1,000,000 byte file with VIM.
Just to be clear, of course I am aware of bult-in Linux utilities such as dd, ut I am trying to figure out what is wrong with VIM to understand how to use that tool better in the future. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Create a 1,000,000 byte file with VIM.
On Tue, Sep 11, 2012 at 2:29 PM, Karol Samborski edv.ka...@gmail.com wrote: Hi, Why not just: iaesc - insert 'a' yl- copy one character 100p- paste it 100 times Because that would give me a 101 byte file! Seriously, though, thanks. This is the correct way! Interestingly, though there is no trailing whitespace, I had to have only 99 characters to get a 100 file, in other words there is an extra byte in there somewhere. Perhaps a BOM due to the UTF-8 file system? -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Create a 1,000,000 byte file with VIM.
On Tue, Sep 11, 2012 at 2:34 PM, John Beckett johnb.beck...@gmail.com wrote: Dotan Cohen wrote: I am trying to create a 1,000,000 byte file with VIM. The following has VIM using 100% of _both_ my CPUs (Intel DuoCore) for almost two hours before I killed it: iaesc100. Vim is for editing text, not performing arbitrary operations. One problem with the above (on a normal Vim, if no special commands have been entered first), is that Vim will try to maintain an undo list. That is a good point. I didn't even think about the undo list. However, I must mention that only CPU was swamped, the memory usage was not noticeably affected. Nevertheless, it is possible to have Vim quickly write a file consisting of a single line of one million 'a' characters: :call writefile([repeat('a', 100)], 'a.tmp', 'b') The 'b' option (binary) means there is no newline at the end. Omit , 'b' if a newline is wanted. Nice. thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Create a 1,000,000 byte file with VIM.
On Tue, Sep 11, 2012 at 2:50 PM, Erik Christiansen dva...@internode.on.net wrote: On 11.09.12 14:34, Dotan Cohen wrote: I had to have only 99 characters to get a 100 file, in other words there is an extra byte in there somewhere. If ff is unix, then a '\n' is appended to the line. (It's what I had expected, and od -c shows that that is what vim does.) Thanks, Erik, the use of od is rather useful! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Create a 1,000,000 byte file with VIM.
On Tue, Sep 11, 2012 at 5:25 PM, Tony Mechelynck antoine.mechely...@gmail.com wrote: I think that the following will create a file containing one million spaces (and *no* carriage-return after them). I haven't tested it. It mixes ex-commands and normal-mode commands. It assumes that the current file is not modified. It will fail (with an error) if the required features are not compiled-in. Space and Esc are one keypress each. It assumes that ^ is a valid character in a filename, which is true under Unix/Linux; I don't know about Windows. :enew :setlocal virtualedit=all binary noeol :set undolevels=0 nobackup nowritebackup 100| iSpaceEsc :saveas 10^6spc.txt For a million 'a' instead, add :s/ /a/g before the :saveas but that :substitute operation may be costly. Thanks, there is much interesting stuff in there. This is quite why I asked the question! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Vim for iPad
On Fri, Jan 20, 2012 at 1:43 PM, Bram Moolenaar b...@moolenaar.net wrote: Hello Vim and iPad users, If you have an iPad, you can now run Vim on it: http://applidium.com/en/applications/vim/ Obviously not having a keyboard is a drawback, but otherwise it appears to work well. Hi Bram! I just found a terrific software keyboard on Github, licensed under the MIT license, you might want to see about incorporating it with VIM on the iDevices: https://github.com/adamhoracek/KOKeyboard -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Enable option / disable option
On Superuser I found this nice way to highlight the word under the cursor for the whole page: :autocmd CursorMoved * exe printf('match IncSearch /\V\%s\/', escape(expand('cword'), '/\')) http://superuser.com/questions/255024/vim-highlighting-a-search-term-without-moving-the-cursor I would like to enable / disable this feature, for instance on leaderh. Is there any way to do this? I could write a function to set the option, but how to disable it afterwards, and how to check the state so that the same key could toggle? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Enable option / disable option
On Tue, Jul 31, 2012 at 3:23 PM, geoffrey.w...@thomsonreuters.com wrote: On Tuesday, 31 July 2012 12:51:52 UTC+1, dotancohen wrote: Here's another way to highlight the word under the cursor http://vim.wikia.com/wiki/VimTip1572 If you use this plugin, you can simply enable the functionality \m then use a NumPad key to assign a colour to that word everywhere without moving your cursor. 1 You can us many different highlights at once for many different words, or more complex search patterns if you wish. Doesn't answer your programming question of course, just evades it :) regards, Geoff That's fine, I'm married and thus used to my questions being evaded :) The problem with that plugin is: א) It requires leaving the home row, and ב) I don't have a numpad on some keyboards that I use! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Enable option / disable option
On Tue, Jul 31, 2012 at 3:24 PM, Benjamin R. Haskell v...@benizi.com wrote: Leaderh toggles the under-cursor highlighting :map Leaderh let g:under_cursor_hl = 1 - get(g:, 'under_cursor_hl', 1) Use it in the CursorMoved autocmd :autocmd CursorMoved * if get(g:, 'under_cursor_hl', 1) | exe printf('match IncSearch /\V\%s\/', escape(expand('cword'), '/\')) | end Or am I missing something? Thanks, Ben. The problem is that I cannot turn the feature off! That was the question in the OP, with a different method of achieving the same effect. My ultimate goal is to be able to set specific words to be highlighted, say toggling them with \hw (highlight word), and _also_ to have the ablility to toggle highlight-word-under-cursor, say with \hh. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM scrollbar
On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt cbli...@256bit.org wrote: The development version of DynamicSigns now also contains a Sign-Scrollbar. You can find it here: https://github.com/chrisbra/DynamicSigns Thank you, I installed the version from Git. I've noticed that in DOS-formatted files there are some issues. Each line has an M, even those without mixed indentation. Signs_Diff doesn't seem to work, either. Signs_Bookmarks does, though. If you want I can send to you a test file. Also, how does one configure the plugin to start when opening a file? I must type :Signs every time I open a file. Adding :Signs or Signs to .vimrc does not start the pluging automatically (In fact, VIM complains that it is not a command when in .vimrc). Also, I don't see the status bar added. Additionally, I notice that changes are not automatic, rather after each line change one must run :UpdateSigns to have them updated. Might it not be better to do this whenever the user leaves Insert mode or adds a sign? I'm not complaining, but letting you know what I've experienced. I like the fact that I can now see marks and I can use the statusbar code that you mentioned earlier. Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM scrollbar
On Sun, Jul 8, 2012 at 3:39 PM, Christian Brabandt The development version of DynamicSigns now also contains a Sign-Scrollbar. You can find it here: https://github.com/chrisbra/DynamicSigns Thanks Christian! I notice that the plugin has a makefile, but I found no vimball. Is it alright then to just import it all into the proper VIM directories? I don't use Pathogen or any such VIM package managers. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM scrollbar
On Tue, Jul 3, 2012 at 9:35 PM, Christian Brabandt cbli...@256bit.org wrote: I used to have this one in my .vimrc (it's based on a tip by A.Politz): https://groups.google.com/group/vim_use/msg/e7c193ad5dc9c136 Thank you Christian, this is great! In the status bar it takes up no additional screen space either. There is a ton of stuff that I don't understand in there, so I'll see what I can decipher with VIM help. If you are on Stack Overflow or Super User you might want to post that as an answer. I'm still holding out for marks in the statusbar, I will try to see if I can add them myself. Three questions that might get me on my way: 1) For mark 'n' how might I find which line it is on, i.e. get a variable nLine? 2) Assuming a string 'bar', how might I read an arbitrary character in that string? 3) Assuming a string 'bar', how might I replace an arbitrary character in that string? I read through ':h functions' and for (2) I thought that get() would work, but it doesn't. And for (3) I was hoping for a put() function but there is none. Is there something that I'm missing or should I write my own helper functions for this? Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM scrollbar
On Wed, Jul 4, 2012 at 10:37 AM, Christian Brabandt cbli...@256bit.org wrote: I only very seldomly post there, but I'll do it this time. I'll probably also add some kind of vertical scrollbar into my DynamicSigns plugin. Then the bounty will help! I'll take a look at the DynamicSigns plugin, the name sounds useful. I'm still holding out for marks in the statusbar, I will try to see if I can add them myself. Three questions that might get me on my way: 1) For mark 'n' how might I find which line it is on, i.e. get a variable nLine? :h getpos() Possibly using one of the match-functions or using indexing like bar[2] :h expr8 :h match() :h substitute() Thank you, it looks like those are all the critical pieces. When I get something working I'll post it. Mit freundlichen Grüßen Christian Danke Jungs! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Going back to empty brackets and quotes
On Sat, Jun 23, 2012 at 10:18 PM, Christian Brabandt cbli...@256bit.org wrote: Hi Dotan! On Sa, 23 Jun 2012, Dotan Cohen wrote: On Thu, Jun 21, 2012 at 10:40 PM, Christian Brabandt cbli...@256bit.org wrote: Hi Dotan! On Do, 21 Jun 2012, Dotan Cohen wrote: Hello, I have this terrific mapping which takes me back to the previous empty brackets or quotes: inoremap jk c-o?\({}\\|\[]\\|\\|\\|()\\|\\|''\\|lt\)?s+1Return This works great if there is no whitespace between the empty brackets / quotes, so I added the whitespace check: inoremap jk c-o?\({\s*}\\|\[\s*]\\|\s*\\|\s*\\|(\s*)\\|\s*\\|'\s*'\\| \s*lt\)?s+1Return However, this new regex leaves the cursor at the first character inside the brackets. I would like it to be at the half-way point, as sometimes there is no whitespace, sometimes a single space, and sometimes a double space depending on nestling: if (something) {} if ( someFunc(something) ) {} if ( someFunc(something) || otherFunc(something) ) To write that code, I will do: if () {}| ^ Here I press jk if ( ) {}| ^ Here I press jk if ( ) {}| ^ Here I press jk Is there any way to put the cursor right in the middle of the brackets? I tried to write a function which would calculate the amount of whitespace characters between the brackets and would then press Right half that many times, but I completely failed. I then tried to select until the next bracket, replace all double whitespace characters with a single whitespace, set a mark, paste the now-half-size selection again, and then return to the mark. That didn't work out so well either! What approach should I be taking? I am not exactly sure, what an empty bracket is supposed to be, but this should get you a start: fun! s:SearchPair() abort let spat='\([[({'']\)' let epat='\([])}'']\)' call search(spat. '\(\s\+'. epat. '\)\@=', 'bW') exe ':norm! v/'. epat. \CR\ESC let len = getpos(')[2] - getpos(')[2] exe :norm! . (getpos(')[2] + len/2 + 1). | endfu inoremap jk c-\c-o:call sidSearchPair()cr Thank you Christian! This is a good start for me to build upon, it is full of things that I am unfamiliar with. It is pretty broken for most uses, but I think that I can learn from it, which I suspect was quite the intent! The getpos line is obviously where the magic occurs. A few questions: Thanks, Christian! What is sid? sid is a way to prevent polluting the global Vim namespace with names from functions and plugins. It get resolved by Vim to something like snrXXX_functionname, where XXX is the name, that you can find in the output of :scriptnames (which tells you the order of loaded files). See als :h sid Thanks. That is an interesting solution to the namespaces issue, I will have to read more about that. How can I get the character that was matched by: ?\({\s*}\\|\[\s*]\\|\s*\\|\s*\\|(\s*)\\|\s*\\|'\s*'\\|\s*lt\)?s+1Return Not sure. May be using matchstr() function and a like. It is hard to read, especially since you had to double the backslashes. Yes, I figured that it was a mess! I basically matches these character pairs, separated by whitespace: {} [] () '' I would use this to try to find the next match and compute the distance between them. What is the mnemonic for spat and epat? I cannot figure out why you choose those variable names! I feel that if I know what they stand for then the search line will become clearer as I'm not sure why it is built the way that it is. That is easy. It is StartPATtern and EndPattern (e.g. Start would be the opening paranthesis and End would be the closing paranthesis). Ah! I figured that it was start* and end*! Thanks. If you describe in detail, what the function does and what you expect (best would be with sample text), I might be able to improve the version. I would like the function to search backwards in the text for the above-mentioned character pairs. If such a pair is found (separated by possible whitespace), then I would like the cursor to be moved to the character location halfway between them. If no pairs are found, then the function would silently do nothing. However, don't start coding! Although I appreciate code samples of course, my real goal is to figure out how to write this function on my own. I had no idea where to start so I asked the list. But you have given me very specific tips and I can probably take it from here. Thank you very much, your assistance and advice is very much appreciated! Have a peaceful week! I will update the thread when I have something concrete that works. Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Going back to empty brackets and quotes
Hello, I have this terrific mapping which takes me back to the previous empty brackets or quotes: inoremap jk c-o?\({}\\|\[]\\|\\|\\|()\\|\\|''\\|lt\)?s+1Return This works great if there is no whitespace between the empty brackets / quotes, so I added the whitespace check: inoremap jk c-o?\({\s*}\\|\[\s*]\\|\s*\\|\s*\\|(\s*)\\|\s*\\|'\s*'\\| \s*lt\)?s+1Return However, this new regex leaves the cursor at the first character inside the brackets. I would like it to be at the half-way point, as sometimes there is no whitespace, sometimes a single space, and sometimes a double space depending on nestling: if (something) {} if ( someFunc(something) ) {} if ( someFunc(something) || otherFunc(something) ) To write that code, I will do: if () {}| ^ Here I press jk if ( ) {}| ^ Here I press jk if () {}| ^ Here I press jk Is there any way to put the cursor right in the middle of the brackets? I tried to write a function which would calculate the amount of whitespace characters between the brackets and would then press Right half that many times, but I completely failed. I then tried to select until the next bracket, replace all double whitespace characters with a single whitespace, set a mark, paste the now-half-size selection again, and then return to the mark. That didn't work out so well either! What approach should I be taking? Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Where in the manual are i, o, and a as in ciw cow caw?
On Wed, Jun 6, 2012 at 10:03 PM, Tim Chase v...@tim.thechases.com wrote: On 06/06/12 13:54, Dotan Cohen wrote: I understand the use of i in ciw, but I am not quite sure about o and a. Where can these be found in the fine manual? Of course, :h i does not lead own to them, because it leads one to the Insert text. you want to read up at :help text-objects (there's no o, AFAIK, just the a and i) Thank you Tim! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Where in the manual are i, o, and a as in ciw cow caw?
On Wed, Jun 6, 2012 at 10:26 PM, Gary Johnson garyj...@spocom.com wrote: On 2012-06-06, Dotan Cohen wrote: I understand the use of i in ciw, but I am not quite sure about o and a. Where can these be found in the fine manual? Of course, :h i does not lead own to them, because it leads one to the Insert text. :help aw :help iw There is no ow that I know of. Regards, Gary I did not realise that one could combine the i and w in the help search like that. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Where in the manual are i, o, and a as in ciw cow caw?
I understand the use of i in ciw, but I am not quite sure about o and a. Where can these be found in the fine manual? Of course, :h i does not lead own to them, because it leads one to the Insert text. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Show me the text, even if it might be autocompleted!
On Sun, May 13, 2012 at 9:37 PM, Tim Chase v...@tim.thechases.com wrote: On 05/13/12 10:58, Dotan Cohen wrote: I have a few of these wonderful helpers: inoremap foreachReturn foreach (SpaceSpace)Return{ReturnR eturn}Esc3kALeftLeft I know that there is a snippets plugin, but I like this roll-my-own solution for a number of reasons (one of which is to learn Vim). However, one problem that I have is that the text f-o-r-e-a-c-h is not shown until I get to the end of the map. Is there any way to configure VIM to show the text normally, until it decides that there will be a replacement? This is driving me crazy. You might try it with an abbreviation instead: :iab foreach foreach(space)cr{crcr}upupupendleftleft which allows you to see it as you type it (also expands on space which I prefer over enter). Setting 'showcmd' doesn't quite do it (it shows each letter in-place), but it's not a bad followup solution. Thanks, Tim. I did not know about iab, thank you. There are a few caveats: 1) I have one foreach that expands on space to give: foreach ( | ) And another which expands on return to give: foreach ( | ) { } I can live with having just the latter and having it expand on space, but it is a drawback so I mention it. 2) The iab abbreviations add a space after the mapping, which is precludes many combinations such as if I want to leave the cursor between two parentheses. 3) The iab abbreviations will not work in the general case for remapping handy things which do not end in a space, such as these: inoremap ii Esc inoremap kk EscA Go back to between the last {} [] () '' or inoremap hh c-o?\%c-r=line('.')Returnl\({}\\|\[]\\|\\|\\|()\\|\\|''\\| lt\)?s+1Return inoremap ;; EscA;Return For adding another method argument while inside quotes inoremap ,, Right,Space For adding = while inside quotes (PHP associative arrays) inoremap ,,j RightSpace=Space In all these cases the user is stuck watching a cursor that does not move according to his typing. I know the reasons behind not showing the text (the text might never be entered into the buffer). However, the feedback of seeing the text, even if it is not intended for being added to the buffer, is very important. In any case, by far _most_ of the leading characters are used outside the mappings, so it is the common case that is being made annoying for the sake of the uncommon case. If need be, I would prefer that the text be added to the buffer and then removed if it matches a map. Is there any way to accomplish this? Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Show me the text, even if it might be autocompleted!
On Mon, May 14, 2012 at 3:48 PM, Benjamin R. Haskell v...@benizi.com wrote: See the Eatchar function in the help for map.txt: :help map.txt | /Eatchar I use the following variant of Eatchar (since '\s' is the common case): fun! Eatchar(...) let c = nr2char(getchar(0)) return c =~ (a:0 ? a:1 : '\s') ? '' : c endf Then, in the example Tim provided above, the iab becomes: :iab foreach foreach(space)cr{crcr}upupupendleftleftC-R=Eatchar()CR Terrific, thank you. I cannot believe how deep this rabbit hole goes! Every time I think maybe VIM could be just a tad better I discover that it _can_ be, but I had better be prepared to read some obscure passages of the fine manual! I would be completely lost without the help of the wonderful people on this mailing list. Thank you for now only showing me what needs to be done, but for showing me where to find it in the manual. Teaching me to fish! 3) The iab abbreviations will not work in the general case for remapping handy things which do not end in a space, such as these: inoremap ii Esc inoremap kk EscA Go back to between the last {} [] () '' or inoremap hh c-o?\%c-r=line('.')Returnl\({}\\|\[]\\|\\|\\|()\\|\\|''\\| lt\)?s+1Return inoremap ;; EscA;Return For adding another method argument while inside quotes inoremap ,, Right,Space For adding = while inside quotes (PHP associative arrays) inoremap ,,j RightSpace=Space In all these cases the user is stuck watching a cursor that does not move according to his typing. I know the reasons behind not showing the text (the text might never be entered into the buffer). However, the feedback of seeing the text, even if it is not intended for being added to the buffer, is very important. Trying these mappings, I see the first letter of the mapping appear under the cursor (though the cursor doesn't move until the next key is typed). Is it really that disconcerting? (Typing a normal word at normal speed, it doesn't seem that noticeable to me.) I can live with it. I just find that after a few weeks (months for some letters like 'i') I still loose my train of thought when I see my cursor not moving as I expect. I thought that I would get used to the issue, but I see that I'm not. I can still function, though. In any case, by far _most_ of the leading characters are used outside the mappings, so it is the common case that is being made annoying for the sake of the uncommon case. If need be, I would prefer that the text be added to the buffer and then removed if it matches a map. I could be wrong, but I don't think mapping things that start with letters in insert mode is the common case. (Though, that might be because of the issue we're discussing.) My personal preference is to not map anything in insert mode at all, except via abbreviations. And a lot of people seem to prefer F# keys. I like to keep my fingers on the home row, this is the reason that I started using VIM in the first place. You'll notice that the letter-started mappings are all there to avoid using the Arrow keys or Esc key. Is there any way to accomplish this? Not as far as I know. Well, we tried! Thank you Ben. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Show me the text, even if it might be autocompleted!
On Mon, May 14, 2012 at 4:19 PM, Benjamin R. Haskell v...@benizi.com wrote: A lot of people seem to like remapping CapsLock to Esc. (Which needs to be done at the O/S level.) And if you're in gvim (not terminal vim, right now), you can use: :ino[remap] ino S-CR Esc Thanks. Actually, I do have CapsLock remapped to Esc but among the problems that I have with my hands, my pinky fingers are starting to hurt. I've come up with all sorts of creative solutions but in the end, I keep returning to a normal keyboard layout and I just need to use them as little as possible. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Show me the text, even if it might be autocompleted!
I have a few of these wonderful helpers: inoremap foreachReturn foreach (SpaceSpace)Return{ReturnR eturn}Esc3kALeftLeft I know that there is a snippets plugin, but I like this roll-my-own solution for a number of reasons (one of which is to learn Vim). However, one problem that I have is that the text f-o-r-e-a-c-h is not shown until I get to the end of the map. Is there any way to configure VIM to show the text normally, until it decides that there will be a replacement? This is driving me crazy. Note that I also have hh, ii, ll, {{, and ;; mapped to handy replacements, and every time I type an h, i, l, { or ; character I go nuts when the cursor does not move as expected. I am one of those funny people who look at the monitor, not the keyboard, when I type! Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Toggle paste and nonu in one keystroke
On Fri, May 11, 2012 at 3:09 PM, Jürgen Krämer jottka...@googlemail.com wrote: have a look at :help 'pastetoggle' although this won't help you at resetting the 'number' option: :inoremap F2 Esc:set nu! paste!cr :set pastetoggle=F2 Regards, Jürgen Thank you Jürgen. As you mention, though, that only solves half the issue! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Toggle paste and nonu in one keystroke
Hi all, I am trying to write a function that will toggle the states paste nonu and nopaste nu. I cobbled a few things together but although I figured this would be easy, it is eluding me. I need some sort of persistent variable to test state mode. I also need it to work in both Insert and Normal modes. noremap F2 PasteMode() function! PasteMode() if exists(SOME_TYPE_OF_PERSISTENT_VARIABLE) unset PERSISTENT_VARIABLE set nopaste set nu else set PERSISTENT_VARIABLE set paste set nonu endif endfunction Thanks in advance for any advice. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Toggle paste and nonu in one keystroke
On Fri, May 11, 2012 at 2:25 PM, Christian Brabandt cbli...@256bit.org wrote: This is way too complicated, :set allows to toggle values by itself (:h :set-!), so this should work: :nnoremap f2 :set nu! paste!cr Thanks, Christian, that is very helpful! However I am having trouble with the Insert version. I am trying this code: :inoremap F2 Esc:set nu! paste!cr However, when I press F2 in Insert mode I get the text F2 inserted into the document! Also, I will have trouble with reentering Insert mode, because if I use i or a then I will have troubles at the end or beginning of text lines. Is there a workaround for that? Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Toggle paste and nonu in one keystroke
On Fri, May 11, 2012 at 2:58 PM, Christian Brabandt cbli...@256bit.org wrote: However I am having trouble with the Insert version. I am trying this code: :inoremap F2 Esc:set nu! paste!cr However, when I press F2 in Insert mode I get the text F2 inserted into the document! Well, by definition in paste mode, mappings aren't executed (:h 'paste') That makes perfect sense! Thanks. Also, I will have trouble with reentering Insert mode, because if I use i or a then I will have troubles at the end or beginning of text lines. Is there a workaround for that? :h i_CTRL-\_CTRL-O Thanks, that is exactly what I need. Have a terrific weekend. Thank you for the advice! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: No ~/.vim/after/syntax/php.vim
On Mon, May 7, 2012 at 5:56 PM, Benjamin R. Haskell v...@benizi.com wrote: syn match phpPlusEq '+=' It worked for me after changing that line to: syn match phpPlusEq '+=' containedin=phpOperator Thanks, Ben! I changed the line as you mention, but still no highlighting of the += operator, even though I can see the file is being sourced. I will say, though, that this issue brought my attention to the operator so forward in my mind that I am much more mindful of it. I dare say that I may be less prone to making the .= / += mistake now. The root of the problem is PHP usage of the . operator for string concatenation, vs. Javascript / Java / C# usage of += for the same. PHP _does_ use += for integer/float addition, and on top of that PHP will silently cast a string to an int (value: 0) if the += operator is used on it, then silently overwrite the weakly-typed variable with the integer! TRWFT is PHP. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: No ~/.vim/after/syntax/php.vim
On Thu, May 3, 2012 at 11:49 PM, Gary Johnson garyj...@spocom.com wrote: On 2012-05-03, Dotan Cohen wrote: On Thu, May 3, 2012 at 10:34 PM, Ben Fritz wrote: It shouldn't, without a syntax/php.vim file somewhere. As noted, this file is only sourced as-needed; is the output of the :scriptnames command you gave from a Vim with the php file loaded and syntax highlighting on as you describe? In that Vim, what does this command say? The PHP syntax is probably being sourced from whatever the default is in /etc or /usr :verbose set syntax? filetype? syntax=php Last set from /usr/share/vim/vim73/syntax/syntax.vim filetype=php Last set from /usr/share/vim/vim73/filetype.vim Neither of those files was in the :scriptnames output that you posted originally. 1: /usr/share/vim/vimrc 2: /usr/share/vim/vim73/debian.vim 3: /usr/share/vim/vim73/syntax/syntax.vim 4: /usr/share/vim/vim73/syntax/synload.vim 5: /usr/share/vim/vim73/syntax/syncolor.vim 6: /usr/share/vim/vim73/filetype.vim 7: /home/dotancohen/.vimrc 8: /home/dotancohen/.vim/keymap/insert-only_capslock.vim 9: /home/dotancohen/.vim/plugin/taglist.vim 10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim 11: /usr/share/vim/vim73/plugin/gzip.vim 12: /usr/share/vim/vim73/plugin/matchparen.vim 13: /usr/share/vim/vim73/plugin/netrwPlugin.vim 14: /usr/share/vim/vim73/plugin/rrhelper.vim 15: /usr/share/vim/vim73/plugin/spellfile.vim 16: /usr/share/vim/vim73/plugin/tarPlugin.vim 17: /usr/share/vim/vim73/plugin/tohtml.vim 18: /usr/share/vim/vim73/plugin/vimballPlugin.vim 19: /usr/share/vim/vim73/plugin/zipPlugin.vim 20: /home/dotancohen/.vim/after/plugin/matchparen.vim 21: /usr/share/vim/vim73/scripts.vim Press ENTER or type command to continue That means that they were sourced AFTER you executed that :scriptnames command but BEFORE you executed :verbose set syntax? filetype? So try the :scriptnames command again but this time AFTER you open a PHP file. Apparently I erred, I apologise for driving everyone crazy. Here is the :scriptfiles output for a PHP file: 1: /usr/share/vim/vimrc 2: /usr/share/vim/vim73/debian.vim 3: /usr/share/vim/vim73/syntax/syntax.vim 4: /usr/share/vim/vim73/syntax/synload.vim 5: /usr/share/vim/vim73/syntax/syncolor.vim 6: /usr/share/vim/vim73/filetype.vim 7: /home/dotancohen/.vimrc 8: /home/dotancohen/.vim/keymap/insert-only_capslock.vim 9: /home/dotancohen/.vim/plugin/taglist.vim 10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim 11: /usr/share/vim/vim73/plugin/gzip.vim 12: /usr/share/vim/vim73/plugin/matchparen.vim 13: /usr/share/vim/vim73/plugin/netrwPlugin.vim 14: /usr/share/vim/vim73/plugin/rrhelper.vim 15: /usr/share/vim/vim73/plugin/spellfile.vim 16: /usr/share/vim/vim73/plugin/tarPlugin.vim 17: /usr/share/vim/vim73/plugin/tohtml.vim 18: /usr/share/vim/vim73/plugin/vimballPlugin.vim 19: /usr/share/vim/vim73/plugin/zipPlugin.vim 20: /home/dotancohen/.vim/after/plugin/matchparen.vim 21: /usr/share/vim/vim73/syntax/php.vim 22: /usr/share/vim/vim73/syntax/html.vim 23: /usr/share/vim/vim73/syntax/javascript.vim 24: /usr/share/vim/vim73/syntax/vb.vim 25: /usr/share/vim/vim73/syntax/css.vim 26: /usr/share/vim/vim73/syntax/sql.vim 27: /usr/share/vim/vim73/syntax/sqloracle.vim 28: /home/dotancohen/.vim/after/syntax/php.vim 29: /usr/share/vim/vim73/scripts.vim 30: /usr/share/vim/vim73/syntax/help.vim I see that ~/.vim/after/syntax/php.vim is in there. However, the += string is certainly not being highlighted as error. Here is the content of the ~/.vim/after/syntax/php.vim file: scriptencoding utf-8 setlocal nolist syn match phpPlusEq '+=' hi link phpPlusEq Error I also tried with a keyword definition instead of match, this did not work to highlight += either: scriptencoding utf-8 setlocal nolist syn keyword phpPlusEq += highlight phpPlusEq term=reverse ctermfg=black ctermbg=yellow guifg=black guibg=yellow -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
No ~/.vim/after/syntax/php.vim
I am trying to get the =+ operator highlighted as an error in PHP files. I have this file: $ cat /home/dotancohen/.vim/after/syntax/php.vim scriptencoding utf-8 setlocal nolist syn match phpPlusEq '+=' hi link phpPlusEq Error vim: ts=8 sw=2 $ However, it is not showing in my list of scriptnames: 1: /usr/share/vim/vimrc 2: /usr/share/vim/vim73/debian.vim 3: /usr/share/vim/vim73/syntax/syntax.vim 4: /usr/share/vim/vim73/syntax/synload.vim 5: /usr/share/vim/vim73/syntax/syncolor.vim 6: /usr/share/vim/vim73/filetype.vim 7: /home/dotancohen/.vimrc 8: /home/dotancohen/.vim/keymap/insert-only_capslock.vim 9: /home/dotancohen/.vim/plugin/taglist.vim 10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim 11: /usr/share/vim/vim73/plugin/gzip.vim 12: /usr/share/vim/vim73/plugin/matchparen.vim 13: /usr/share/vim/vim73/plugin/netrwPlugin.vim 14: /usr/share/vim/vim73/plugin/rrhelper.vim 15: /usr/share/vim/vim73/plugin/spellfile.vim 16: /usr/share/vim/vim73/plugin/tarPlugin.vim 17: /usr/share/vim/vim73/plugin/tohtml.vim 18: /usr/share/vim/vim73/plugin/vimballPlugin.vim 19: /usr/share/vim/vim73/plugin/zipPlugin.vim 20: /home/dotancohen/.vim/after/plugin/matchparen.vim 21: /usr/share/vim/vim73/scripts.vim Press ENTER or type command to continue Why might that be? This is on Kubuntu 11.10, KDE 4.7 with VIM 7.3. My ~/.vim/after/plugin/matchparen.vim file works as expected, so it seems that the after files are supported. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: No ~/.vim/after/syntax/php.vim
the first obvious question is: does vim recognize the filetype of whatever you are editing as 'php'? I can confirm that the file is named someFile.php and that other PHP code in the file is in fact highlighted. For instance, someVar is not highlighted whereas $someVar is highlighted. Likewise, strblah() is not highlighted whereas strlen() is highlighted. So it looks like PHP-specific highlighting to me. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: No ~/.vim/after/syntax/php.vim
On Thu, May 3, 2012 at 10:34 PM, Ben Fritz fritzophre...@gmail.com wrote: It shouldn't, without a syntax/php.vim file somewhere. As noted, this file is only sourced as-needed; is the output of the :scriptnames command you gave from a Vim with the php file loaded and syntax highlighting on as you describe? In that Vim, what does this command say? The PHP syntax is probably being sourced from whatever the default is in /etc or /usr :verbose set syntax? filetype? syntax=php Last set from /usr/share/vim/vim73/syntax/syntax.vim filetype=php Last set from /usr/share/vim/vim73/filetype.vim And what is the value of b:current_syntax? I'm not sure what you mean by that. What command exactly should I be running? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: No ~/.vim/after/syntax/php.vim
On Thu, May 3, 2012 at 11:14 PM, Charles Campbell :echo b:current_syntax Thanks, it is in fact php. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Matchtime not working
I seem to have trouble with the matchtime option. As I understand it, this option will show the matching-brace highlight for a short time, then disappear. I cannot get this option to work, instead in all environments the matching brace is highlighted indefinitely. I am trying in these environments: Konsole in KDE 4.7 and VIM 7.3 Konsole in KDE 4.7 SSHing into CentOS 5.x with VIM 7.0 Putty in Windows XP SSHing into CentOS 5.x with VIM 7.0 GVIM 7.3 in Windows XP A recent Cygwin on Windows XP with VIM, I did not check the version though and I no longer have access to it Cygwin on Windows XP SSHing into CentOS 5.x with VIM 7.0 I have this in .vimrc on all the environments that I tried: set showmatch set matchtime=10 Is this not the right way to use matchtime, or am I understanding the option incorrectly? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: DrChip's website is back!
On Wed, Mar 7, 2012 at 23:18, Charles Campbell charles.e.campb...@nasa.gov wrote: Yes, its back! Albeit at a new webhost (apply your favorite search engine to hostbig). You may find it at: http://www.drchip.org/ Hopefully all my vim pages and content are there and accessible. Let me know if there's problems/something missing. Chip Campbell I see that I'm late to the party, but let me say thank you Chip. I am learning quite a lot from your VIM page. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Matchtime not working
On Tue, May 1, 2012 at 17:39, Taylor Hedberg tmhedb...@gmail.com wrote: The highlighting you are used to is provided by the matchparen plugin. 'showmatch' and 'matchtime' are, on the other hand, for Vim's built-in (i.e. not implemented as a plugin) matching functionality, which, rather than highlighting, jumps the cursor to the matching opening brace/bracket/parenthesis for a brief time after the closing character in the pair is typed. Try typing some opening and closing parentheses after `:set showmatch` and you'll see what I mean. This feature is turned off by default. As far as I know, the matchparen plugin does not refer to the 'matchtime' option to determine how long to highlight; it is either on indefinitely or it is off. Barring modification to the plugin itself, I don't think there's any way to get precisely what you want. Thanks Taylor, I see it now. I was testing with existing code, expecting to put the cursor on a brace and see the match. I now understand that it only works for typing out new code. Is there any way to change the behaviour of the matchparen plugin to underline the matching brace, instead of highlighting it? I often get confused which is the highlighted brace and which brace has the cursor. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Matchtime not working
On Tue, May 1, 2012 at 19:15, Charles Campbell charles.e.campb...@nasa.gov wrote: In quickly diving into matchparen, I see that the matching brace is the MatchParen highlighting group. Consequently, hi clear MatchParen hi MatchParen gui=underline cterm=underline should do the trick. When you're happy with it, put these two lines into .vim/after/plugin/matchparen.vim Regards, Chip Campbell Thank you Chip. That does exactly what I need! I will also take your example and try my hand at delving into the matchparen plugin to learn a bit about how this is done. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 go back after *
On Mon, Apr 9, 2012 at 10:10, Ben Fritz fritzophre...@gmail.com wrote: On Sunday, April 8, 2012 7:13:22 PM UTC-5, dotancohen wrote: :set statusline=%%f%=%([%{Tlist_Get_Tagname_By_Line()}]%) set statusline=%{PHP_Cursor_Position()} function! PHP_Cursor_Position() let pos = getpos(.) let curline = pos[1] let win = winsaveview() let decl = let startline = search('^\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(function\|class\)\s*\=\w\+','cbW') call search('{','cW') sil exe normal % let endline = line(.) if curline = startline curline = endline let decl = getline(startline) endif call cursor(pos) call winrestview(win) return decl endfunction Just a guess, but I'm betting one of these is causing your trouble. First I note with interest that the first of them is always overwritten by the second and thus shouldn't do anything. Then I note that the second will, every time the screen redraws, mess with the cursor position. Although it restores it later, I wonder if it causes problems anyway. Those two statusline bits are some current experimentation of mine, I don't ever have both of them enabled at once. But you are right, putting finish before them fixes all the issues that I have been noticing with VIM lately. I bet it would be possible to rewrite this in a way that it never moves the cursor, using the 'n' flag on the search() commands, and a searchpair() to replace the normal % command. But if it isn't actually the culprit of your jump position problems then it probably doesn't make sense to mess with it, if it works as intended. I will have to look into that I am very new at VIM scripting but I am diving in head first. VIM is quite a deep rabbit hole, it seems that it can do almost anything so long as one is willing to experiment a bit with the scripting. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 go back after *
\|private\)\=\s*\(static\|public\|private\)\=\s*\(function\|class\)\s*\=\w\+','cbW') call search('{','cW') sil exe normal % let endline = line(.) if curline = startline curline = endline let decl = getline(startline) endif call cursor(pos) call winrestview(win) return decl endfunction -- Dotan Cohen http://gibberish.co.il http://what-is-what.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 go back after *
On Sun, Apr 8, 2012 at 20:22, Tim Chase v...@tim.thechases.com wrote: Nothing leaps out at me in your vimrc, but I'd just run through bisecting it by adding finish at various intervals. Start in the middle, if it still fails, move it to 25% otherwise move it to 75%. Lather, rinse, repeat until you oust the offending line(s). Nice tip, thanks. I have already copied it to another file and I am removing bits and pieces trying to find the offending code. Standard debugging technique! I just figured that I would post the file in whole to be told if there are any big no-nos in there! Thank you Tim. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
How to go back after *
If one uses * to find the definition of a constant, how can he return to the location where he pressed *? I tried Ctrl-O but it did not take me back. Furthermore, help * did not have any information regarding how to go back. I was not in Insert mode in the last location so `. will not take me there either. Does one have to set a mark to get back? That seems very annoying. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM Showmarks: highlighting entire file, even after being removed
On Thu, Apr 5, 2012 at 11:40, Ben Fritz fritzophre...@gmail.com wrote: This may be a stupid question, but did you restart Vim after removing the plugin? Actually, closing VIM and reopening did not help, but logging out of the server and logging back in did. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: VIM Showmarks: highlighting entire file, even after being removed
On Thu, Apr 5, 2012 at 13:13, Charles Campbell charles.e.campb...@nasa.gov wrote: Another item - you might want to try removing .viminfo, too. Thanks. I haven't had any problems with showmarks, myself. I suggest clearing up your problem and trying showmarks again. Did the problem occur after you typed :ShowMarks ? That would suggest that it is, indeed, the showmarks plugin causing the problem. The problem occurred when I first opened VIM after installing ShowMarks. I tried to open the showmarks.vim file itself and the issue occurred. I think that I also got a message that ~/.vim/doc/ShowMarks (or similar) was now being created. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
VIM Showmarks: highlighting entire file, even after being removed
I just installed the Showmarks [1] VIM plugin. Now, when opening files the entire file is highlighted in orange! rming the ~/.vim/plugin/showmarks.vim file does not return VIM to it's previous state, the files are still highlighted in orange. What might have happened, and how might I fix it? This is on a CentOS 5.x machine. [1] http://www.vim.org/scripts/script.php?script_id=152 -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
What could be the problem with VIM?
This is my .vimrc file: 1 set nu 2 set laststatus=2 3 4 function! PHP_Cursor_Position() 5 let pos = getpos(.) 6 let curline = pos[1] 7 let win = winsaveview() 8 let decl = 9 let startline = search('^\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(function\|class\)\s*\=\w\+','cbW') 10 call search('{','cW') 11 sil exe normal % 12 let endline = line(.) 13 if curline = startline curline = endline 14 let decl = getline(startline) 15 endif 16 call cursor(pos) 17 call winrestview(win) 18 return decl 19 endfunction 20 21 set statusline=%{PHP_Cursor_Position()} 22 Just opening .vimrc and leaving the curso at the opening position makes the console bell ring repeatedly. What might be the problem? I also have these plugins and files installed: ✈saturn:.vim$ pwd /home/dotancohen/.vim ✈saturn:.vim$ tree . ├── doc │ ├── taglist.txt │ └── tags ├── keymap │ └── insert-only_capslock.vim ├── mytags │ └── framework ├── plugin │ ├── ctags.vim │ └── taglist.vim └── spell This is on Kubuntu 11.10. Does anyone have any idea what the problem might be? Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What could be the problem with VIM?
On Sat, Mar 17, 2012 at 16:49, Benjamin R. Haskell v...@benizi.com wrote: (Minor nit: don't include line numbers -- it makes it slightly annoying to copy-paste). Thanks, I will be more careful about that in the future. Initial thoughts: 9 let startline = search('^\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(static\|public\|private\)\=\s*\(function\|class\)\s*\=\w\+','cbW') You left out 'protected'. Thanks, I'll add it. And you can only have two of those in PHP, not three (static/not) + (one visibility). Right, but I don't know in which order they will appear. Though I guess that only 'static' has to worry about that, what do you think of this: search('^\s*\(static\)\=\s*\(public\|private\|protected\)\=\s*\(static\)\=\s*\(function\|class\)\s*\=\w\+','cbW') I am supposing that all the modifiers must come before function (class can't have any), but I've never seen it any other way anyway. Also, there's an optional space after the return-by-reference marker. Taking those two considerations, and using ___\{,2} instead of ___\= ___\=, you get: let startline = search('^\s*\(\(static\|public\|private\|protected\)\s\+\)\{,2}\(function\|class\)\s*\=\s*\w\+','cbW') Ah, thank you! I knew that there was some syntax for not repeating myself with the 'static' but didn't know if offhand. I should have googled, tsk tsk. Just opening .vimrc and leaving the curso at the opening position makes the console bell ring repeatedly. What might be the problem? No idea. Doesn't happen here under Gentoo w/ 7.3.266 or OpenSUSE w/ 7.3.322 Thanks. I also have these plugins and files installed: Just listing what files you have installed doesn't help much. There's no central registrar for Vim plugin filenames, so e.g. your ctags.vim could be any of several such plugins. If you think it's plugin-related, there are two things to try. First, try disabling them all, by starting Vim with the --noplugin flag. Then, try disabling them individually or in groups by adding 'finish' as the first line of the one(s) you want to disable. It has been open for a few minutes with the --noplugin flag and the bell isn't ringing. So it must be a conflict with one of the plugins. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using i to go back and insert
On Thu, Mar 15, 2012 at 02:52, Tim Chase v...@tim.thechases.com wrote: On 03/14/12 14:47, Dotan Cohen wrote: imap jjEsc?\%c-r=line('.')crl\({}\\|\[]\\|\\|()\\|\\|''\\|lt\)?s+1cri I'd be tempted to use c-o instead of Esc ... i, but I'm glad it's working for you as you desire. I think it only matters if you don't find a match: in the Esc...i version, I think you end up in Normal mode, while the c-o method leaves you in Insert mode. Glad it meets your needs, Thanks, that is a good tip. I appreciate the advice! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Why does this function “skip” on some lines in PHP code?
Hi all, I am having a real hard time with an indeterminate bug in a VIM function. First, here is the function: set cul hi CursorLine term=none cterm=none ctermbg=20 set nu set statusline+=%{WhatFunctionAreWeIn()} set laststatus=2 fun WhatFunctionAreWeIn() let strList = [while, foreach, ifelse, if else, for, if, else, try, catch, case] let foundcontrol = 1 let position = normal mz while (foundcontrol) let foundcontrol = 0 normal [{ ?\S let tempchar = getline(.)[col(.) - 1] if (match(tempchar, )) =0 ) normal % ?\S endif let tempstring = getline(.) for item in strList if( match(tempstring,item) = 0 ) let position = item . - . position let foundcontrol = 1 break endif endfor if(foundcontrol == 0) normal `z return tempstring.position endif endwhile normal `z return tempstring.position endfun This function displays the current PHP function name in the status bar. It is derived from this gem: http://vim.wikia.com/wiki/VimTip1296 Both the original function from the VIM wiki and my derived version suffer an indeterminate bug. Sometimes when scrolling down with J the cursor will jump to the wrong location. When this happens one can simply `z to bring the cursor back to where it should be. I would say that about one line in every 100 lines of PHP that I have triggers the bug. Here is the interesting bit. My home Kubuntu machine and a Debian virtual machine trigger the bug in different places in the same file! A CentOS server that I have access to trigger the bug in yet different places from the first two! This is with an identical file and identical .vimrc configurations. The VIM versions are likely slightly different, but they are all 7.X. I originally asked the question on Stack Overflow before I discovered that each system triggers the bug in different places. Here is the Stack Overflow question: http://stackoverflow.com/questions/9728199/why-does-this-function-skip-on-line-63#comment12370266_9728199 If anybody could take a look and advice me on how to fix the bug I would much appreciate it. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Why does this function “skip” on some lines in PHP code?
On Fri, Mar 16, 2012 at 01:16, Benjamin R. Haskell v...@benizi.com wrote: There are at least two things going on: 1. items in an 'stl' %{} group are expanded. So, if you ever return a line that contains a '%', you'll have trouble. I worked around this by renaming your function from WhatFunctionAreWeIn to RawWhatFunctionAreWeIn, then creating: fun! WhatFunctionAreWeIn() let stl=RawWhatFunctionAreWeIn() let stl=substitute(stl, '\t', ' ', 'g') tabs don't show up right let stl=substitute(stl, '%', '%%', 'g') need to escape %'s return stl endfun Thanks. I suppose that actually wrapping the function to escape the output is preferable to escaping on the return of the function, as it will allow the reuse of the function for other places (such as GVIM might provide the titlebar). 2. The :help for 'stl' states that you shouldn't change text or jump to another window. (See :help textlock). Thanks. My major issue right now is knowing where in the fine manual to poke around. But, even more strongly, you *probably* shouldn't move the cursor in a function called from 'stl'. When your function calls [{ to find the prior block, it moves the displayed text. That's what causes the jump. The problem is that the sequence of events for updating the displayed text seems to vary for different types of movement. I was unable to trigger the bug with C-d and C-u movement, for example. But, I could pretty consistently trigger it (when viewing Vim help files) by rapidly using 'k' to move up a single line. I see. thanks. Here's a much simpler function for what you're trying to do (also more naïve, but it's a trade-off): still used in the same way: e.g.: set statusline+=%{WhatFunctionAreWeIn()} fun! StatusLineSafe(txt) let stl = a:txt let stl = substitute(stl, '\t', ' ', 'g') tabs don't show up right let stl = substitute(stl, '%', '%%', 'g') need to escape %'s return stl endfun fun! WhatFunctionAreWeIn() let strList = ['function', 'class'] let lnum = line('.') - 1 while lnum 0 let line = getline(lnum) let lnum -= 1 if line =~ '^\s*#' simple improvement to skip comments continue endif for item in strList let position = match(line, '\'.item.'\') if position = 0 break endif endfor if position = 0 return StatusLineSafe([line .(lnum+1).] .line) endif endwhile return '' return empty string if it's unknown endfun Thank you Ben! There is much in there that I have to examine in more detail. I do have a working solution that was concocted in the linked StackOverflow page, but there certainly is much in your code that I can learn from. I will spend some time pouring over it. I appreciate your help and your willingness to teach. Have a peaceful night. Thank you. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using i to go back and insert
On Tue, Mar 13, 2012 at 17:05, Tim Chase v...@tim.thechases.com wrote: This expression will go back to one of the character pairs: ?\({}\|[]\|()\|\|''\) However, is there any way to restrict it to the current line? Your mapping could include the line, something like (untested) :nnoremap f4 ?bslash%c-r=line('.')crl\({}\|[]\|()\|\|''\)cr which populates the /\%l atom with the current line-number making use of control-R to insert the result of evaluating an expression (in this case, calling line() to get the current line#). :help /\%l Thank you very, very much Tim. I have been playing with a few combination of this for about an hour or three, but all the VIM scripting knowledge that I have is that which has been acquired in those few hours! I see that I am going down the wrong track. I have been wandering helplessly through the fine manual. Perhaps you could suggest what parts of the manual I should be concentrating on for this endeavour? I did read the help section that you mentioned, and those around it, but I still cannot get the pattern to even match at all in a scripted solution! You might also be interested in adding to your list of search items as your link suggests you might want to land at a tag junction. Right, thanks! I will add them after I get the current matches working. Also, you could shift your destination with an offset if you land one before/after your desired location: :help {offset} Actually, a does in fact insert into the desired location between the parentheses. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using i to go back and insert
On Wed, Mar 14, 2012 at 21:30, Tim Chase v...@tim.thechases.com wrote: I tested a bit and came up with :nnoremap Q ?\%c-r=line('.')crl\({}\\|\[]\\|()\\|\\|''\\|lt\)?s+1cr which seems to do what you intend. Or you can use the line-noise of nnoremap Q ?bslash%c-r=line('.')crl\({}bslashbarbslash[]bslashbar()bslashbarbslashbar''bslashbarltbslash)?s+1cr as I think there are various escaping issues on the backslashes, pipes and square-brackets. I like the ?s+1 to position the cursor because I could then use i_CTRL-O to launch the mapping and end up where I intend: :imap f4 c-of4 And obviously if you want, you can still use ii for your mapping instead of f4 (or whatever other single key you might want). -tim Thanks, I pieced these three together for absolute nirvana: imap ii Esc imap kk EscA imap jj Esc?\%c-r=line('.')crl\({}\\|\[]\\|\\|()\\|\\|''\\|lt\)?s+1cri I haven't found any problems with backslashes in the test cases I played with, so even if there are some corner-case escaping issues I am very pleased with the result. Thank you very much for taking the time to help piece this together, and especially for teaching me and showing me how to understand. That is the real value! I wish to you and to those you love a peaceful evening. Thank you! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using i to go back and insert
On Mon, Mar 12, 2012 at 22:26, Tim Chase v...@tim.thechases.com wrote: On 03/12/12 08:16, Dotan Cohen wrote: On Mon, Mar 12, 2012 at 14:18, Tim Chasev...@tim.thechases.com wrote: While an odd request, is there something I'm missing about just doing :nnoremap ii hi And of course, by this I mean nnoremap ii h :-) I have no problem waiting for the limeoutlen to time out, I already use that for other movements. The problem with the mapping that you mention is that one must press ii for an equivalent h, so moving four spaces to the left requires i. I could get used to pressing 4ii to move four spaces back though. I suppose you could make an expression mapping to a function something like function! IorH() let l:count=0 let l:c=nr2char(getchar()) while l:c == 'i' let l:count += 1 let l:c=nr2char(getchar()) endwhile return (l:count?(repeat('h', l:count)):'i').(l:c) endfunction nnoremap expr i IorH() It feels a little weird using it since it lags by one character while you're in this sub-mode, but it seems to do what you describe. Actually, on my system (Konsole in KDE 4.7) the cursor is shown in the command bar when running the expression, so there is no visual feedback at all! However the expression does express some of the things that I need to know to get the feature to work as I would like it to. Usually when I need to go back a few spaces I need to go between two parentheses or two quotes. I will try to write an expression that looks for '' () {} or [] on the current line, and if found will put the cursor between the characters in insert mode. This expression will go back to one of the character pairs: ?\({}\|[]\|()\|\|''\) However, is there any way to restrict it to the current line? Everything that I search for in Google returns results relevant to search and replace with the /g flag. Of course if it finds no matches the cursor should remain where it is and not wind up at the beginning or end of the line. After I get over that hump I should be able to google my way out! Thank you Tim. I have learned a lot from your examples. Your help is very much appreciated! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Using i to go back and insert
Due to the way that I hold the keyboard [1], I find it difficult to get to H comfortably, though I use this key often in Command mode. Is there a way to configure i to switch to Insert mode as it normally does, but to have ii act as hi, and [n]i act as [n-1]hi? I l know that I can configure each sequence manually, but if there exists a way to define a function or such then I would love to know. Thanks. [1] Index fingers on D and K -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using i to go back and insert
On Mon, Mar 12, 2012 at 14:18, Tim Chase v...@tim.thechases.com wrote: While an odd request, is there something I'm missing about just doing :nnoremap ii hi It works with prefixed counts, allows you to keep insert-mode (though you either have to type a character in insert mode that *isn't* i or wait for 'timeoutlen' to see the results of it) I have no problem waiting for the limeoutlen to time out, I already use that for other movements. The problem with the mapping that you mention is that one must press ii for an equivalent h, so moving four spaces to the left requires i. I could get used to pressing 4ii to move four spaces back though. An outside-the-box solution might be to investigate other horizontal movements that don't involve H. I almost never use h/l for left/right movement, preferring instead to use f/F/t/T, or w/W/b/B/e/E, or %/(/) type movements. It's rare that I need to move only one or two characters left/right, especially if that doesn't land me on a targetable boundary. I actually do move just a few characters to the left fairly often, as mentioned here: http://dotancohen.com/howto/write_code.html That coding style is quite the reason that I actually love VIM! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Textpad to GVIM
On Mon, Mar 5, 2012 at 18:18, Govind i.am.an...@gmail.com wrote: I've been a longtime user of Textpad on windows and transitioning more to Linux. Gedit by itself doesn't have some features I want like a) Columnar mode selection b) ability to sort lines c) Word Wrap (at least nothing that jumped out) I was told that GVIM is pretty good in terms of being able to do stuff, so I want to get started using it. What are my next steps (I've installed it, of course). If you don't already know, you should be forewarned. GVIM is not a drop-in replacement for Textpad. GVIM has a very steep learning curve and you will question how anyone could ever use such a monstrosity many times when you first start using it. GVIM is more of a paradigm than a text editor. That said, after a few weeks of using GVIM you will wonder how you ever did without it. I would say that VIM is my single favourite piece of software, I find it absolutely amazing and even fun to use. Just using VIM is a challenge and an adventure in itself! Seriously, it is a text editor but more than that you will find that one does not simply use VIM but rather one becomes a VIM user. That reminds me: there are only two industries in which the customer is referred to as a user! TL;DR: You will find GVIM frustrating at first, and you will hate it. Once you get over that step, you will fall in love with it. Just stick out those first few weeks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Dr Chip
On Sat, Mar 3, 2012 at 20:27, Charles E Campbell Jr drc...@campbellfamily.biz wrote: Its a new situation -- I'd moved the website to drchip.0sites.net -- but the new website host has apparently decided to fold. There was no warning that the website was going down, although some ftp access to grab stuff is still present for a couple of weeks. The website as hosted is really a mirror, anyway, of what I have on my own computer. So, I'm (again) in a process of finding a new webhost. Unfortunately, unlike before, I won't be able to put in redirects (well, I suppose I could, but they wouldn't be allowed to work). I'll be sending out a note when I get a new host. Regards, Chip Campbell Hi Chip. If you just need to put up a few pages the I would be honoured to host them on dotancohen.com. Of course they would be cited as _your_ work and there will never be an advertisement put there. Unfortunately I cannot give to you FTP / SSH access but you can always email to me the occasional edit. Let me know, it would be an honour to help. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What is below the status line, and how to configure it?
On Mon, Feb 13, 2012 at 00:12, Taylor Hedberg tmhedb...@gmail.com wrote: I believe it's just called the command line, and there's not that much you can configure about it, other than controlling how many lines it takes up and setting 'showcmd' so it shows normal-mode commands as you type them. What did you want to change about it? Thanks, Taylor. I want to have it always show the filename, the buffer number, and the amount of open buffers. I seems wasteful to me to put that info on the statusline and then take up another valuable vertical line. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What is below the status line, and how to configure it?
On Mon, Feb 13, 2012 at 17:23, Andy Wokula anw...@yahoo.de wrote: Not sure how useful that is, but 'ruler' can be customized with 'rulerformat': :set ls=0 ru :set ruf=%40(%n/%{bufnr('$')}\ %f%) :h 'ruf only useful with one window at a time, looks like above ruler only shows the buffer number of the bottom window. Also the ruler's display width seems restricted. Thanks. Where is the set ruf line code documented? I figured out that the leading %40 means forty characters' width, but I would really like to see where this syntax is documented. I did manage to find this page: http://vim.1045645.n5.nabble.com/listing-total-number-of-buffers-in-the-statusline-td1189645.html That page has this code for putting the current buffer number and the total amount of buffers in the command line: set rulerformat=%22(%{g:zbuflistcount};%M%n\ %=%l,%c%V\ %P%) autocmd BufAdd * let g:zbuflistcount += 1 autocmd BufDelete * let g:zbuflistcount -= 1 autocmd VimEnter * call UpdateZBufLC() function UpdateZBufLC() let lst = range(1, bufnr('$')) call filter(lst, 'buflisted(v:val)') let g:zbuflistcount = len(lst) endfunction It doesn't show the filename, but this is close enough. I can always Ctrl-G when I need the filename I suppose. By the way, when I list the buffers with :ls, I cannot select 1, 2 to select the first, second buffers. Is there supposed to be a way to do this? I find that typing :b3 when the buffer list is open to be a bit long for VIM, certainly there is a shorter way! Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What is below the status line, and how to configure it?
On Mon, Feb 13, 2012 at 18:01, Jürgen Krämer jottka...@googlemail.com wrote: Thanks. Where is the set ruf line code documented? I figured out that the leading %40 means forty characters' width, but I would really like to see where this syntax is documented. :help ruf From there you are referred to :help 'statusline' Regards, Jürgen Thank you! I must say, I very much appreciate that you show me how I should have gotten to :help 'statusline' instead of just telling me. That helps me help myself in the future. Have a terrific week! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: C-S-up and C-s-down
On Sun, Feb 12, 2012 at 18:41, Taylor Hedberg tmhedb...@gmail.com wrote: David Gomes, Sun 2012-02-12 @ 15:00:15+: I was wondering of how I can map Ctrl+Shift+Up to select all region above until next blank like, and Ctrl+Shift+Down to select all region below until next blank line. :noremap C-S-Up V'{j :noremap C-S-Down V'}k How's that? What is the ' for? I tried :help v_' and v' (to check ' in visual mode) but there was no help for that, and ' in regular mode (marks) does not seem relevant. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
What is below the status line, and how to configure it?
In the final line of my terminal window in VIM I have a line that serves several purposes: 1) When I first open a file, it shows the filename and some attributes. The line also displays my current line number and column. 2) When I scroll, the filename disappears but the line number and column remain (and are updated in real time). 3) When I search or start : commands (what are these commands called?) then the line only shows the command or search term. How is this line called, and how is it configured? I tried to configure the status line, but adding laststatus=2 to .vimrc makes _another_ line appear above it. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Alias on/off?
On Thu, Jan 26, 2012 at 21:36, Benjamin R. Haskell v...@benizi.com wrote: One thing that I do not understand is where the Ctrl-6 mapping is defined. I would like to change that to something else because I use Ctrl-6 to go back to the original file after gf. Ctrl-^ is the built-in key for toggling keymaps, AFAIK. It might be different between normal and insert mode, though, because Ctrl-6 is listed at: :help CTRL-^ (which is a different action), but not at: :help i_CTRL-^ I see, that makes sense. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Redhat Linux has crippled Vim
On Fri, Jan 27, 2012 at 10:14, howardb21 howard...@gmail.com wrote: Again I say onto you all - on RedHat `enhanced' is not enhanced. It provides very very few extra features. From your earlier email you mention 7.3, that sounds like RHL, not RHEL. That version could be 8 or 10 years old, what VIM version is on there? I do not know how recent of a CentOS or Fedora binary you could run on that, but you won't break anything by trying. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Redhat Linux has crippled Vim
On Thu, Jan 26, 2012 at 18:31, howard Schwartz howard...@gmail.com wrote: This may not be the place to ask about this but: I recently had the misery of trying to work with vim on a Redhat Linux distribution at a university. By default, apparently (version 7.3) is severely crippled with minus signs next to almost every feature one can think of -- command line completion, the ability to format comments -- etc. They call it a ``minimal'' version. Redhat's ``enhanced'' version is not - It adds one or two trivial features. I tried building a decent vim from src.rpm, but had the usual nightmare: libraries were the wrong version, files were in the wrong directory, one had to be root, etc. etc. I tried to build vim from regular source, and laughed at the vim.org claim that ``building vim is easy''. I have never found building a complex binary from source ``easy'' unless one did it on one's own OS, and had full knowledge of the locations and requirements that the original author intended -- dispite the claims of gnu's autoconf etc. Any ideas why Redhat wants to convert vim back to the limitations of the old vi? any ideas where to find an rpm package of vim for fedora or linux that is not severely crippled? OK - that is my tirade. Any suggestions? -- 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 You need to install vim or vim-full or some such package. CentOS and Ubuntu do the same thing, it is not big deal. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Redhat Linux has crippled Vim
On a recent CentOS I see it is vim-enhanced: # yum install vim-enhanced -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Redhat Linux has crippled Vim
On Thu, Jan 26, 2012 at 19:27, Taylor Hedberg tmhedb...@gmail.com wrote: Dotan Cohen, Thu 2012-01-26 @ 19:23:10+0200: On a recent CentOS I see it is vim-enhanced: howard Schwartz, Thu 2012-01-26 @ 08:31:02-0800: Redhat's ``enhanced'' version is not - It adds one or two trivial features. According to yum: : Install the vim-enhanced package if you'd like to use a version of the : VIM editor which includes recently added enhancements like : interpreters for the Python and Perl scripting languages. You'll also : need to install the vim-common package. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Alias on/off?
Is there a way to turn 26 alias on and off with a single command? My line of thinking is to enable CapsLock in VIM itself, as opposed to in the OS, so that it will only affect input mode. Can this be done? Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Alias on/off?
On Thu, Jan 26, 2012 at 21:00, Benjamin R. Haskell v...@benizi.com wrote: Is there a way to turn 26 alias on and off with a single command? My line of thinking is to enable CapsLock in VIM itself, as opposed to in the OS, so that it will only affect input mode. Can this be done? See: http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock The gist: use a keymap, which doesn't affect normal/visual mode, but does change keys in insert mode and searches. There's a sample keymap on that page, which swaps A-Z and a-z. I posted a keymap on this list at some point which swaps the case of everything in Unicode that has a mapping to the opposite case: http://benizi.com/vim/swapcaps.vim Thank you Ben, that is exactly what I was trying to do. One thing that I do not understand is where the Ctrl-6 mapping is defined. I would like to change that to something else because I use Ctrl-6 to go back to the original file after gf. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What did I do?
On Wed, Jan 18, 2012 at 16:06, Eric Weir eew...@bellsouth.net wrote: If you use CapsLock often, you might want to read this: http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock Thanks, Dotan. Of the many suggestions made here I need to make some decisions about ways to keep myself apprised of the status of Capslock and whether I'm in visual mode or not. I have CapsLock and Esc swapped, but I do use CapsLock when typing SQL into code that someone else may maintain. I have a bit KDE widget that lights up whenever CapsLock is on, for the simple reason that I never look at my keyboard. Now that I'm using vim I use Esc a lot more than I ever did previously, and have often wished I the Esc key on my computer--a 13 MacBook--was larger. Would you mind sharing the mappings you use to swap the Capslock and Esc keys? [I take it the remapping would only be in effect in vim?] Sorry for the delay. Switching CapsLock and Escape is a KDE feature, though I would assume that your Mac should have something similar. Check in the same place that you would set the keyboard layouts and such. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: What did I do?
On Mon, Jan 16, 2012 at 16:54, Eric Weir eew...@bellsouth.net wrote: This morning, working in a large text document, I realized that all of a sudden all the upper case characters had been converted to lowercase. It seems I accidentally issued a command that has that effect. I believe at the time I had caps-lock on, had forgotten that, and issued a commonly-used command, probably a motion command, with it in effect. Fortunately I had saved recently and was able to recover most of the file from backup. What did I do? If you use CapsLock often, you might want to read this: http://vim.wikia.com/wiki/Insert-mode_only_Caps_Lock I have CapsLock and Esc swapped, but I do use CapsLock when typing SQL into code that someone else may maintain. I have a bit KDE widget that lights up whenever CapsLock is on, for the simple reason that I never look at my keyboard. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Undo assign mark?
If I accidentally press ma instead of 'a, is there any way to revert mark A to its previous value? Assuming, of course, that I do not remember where it was and this is a _long_ file. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: h j k l -- keys
On Mon, Dec 19, 2011 at 07:40, Marty Fried ma...@leftcoast-usa.com wrote: One thing to keep in mind is that the ASCII codes were not really meant to be something that the user typed in, they were *control codes* for controlling printing and display. But some of them were used by users sometimes, and most users knew things like backspace, XON, XOFF, EOF, etc. But I think they were just chosen by what was available, with no regard for mnemonics, or anything. Ctrl-G was bell, Ctrl-M was carriage return, Ctrl-J was linefeed; none of these are related to anything. It does seem to be a happy coincidence that the the linefeed character just happened to be on the strongest finger. Not impossible, but rather convenient. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: h j k l -- keys
On Fri, Dec 16, 2011 at 15:34, rameo rai...@gmail.com wrote: I just want to know why Vim developers (and other software) have chosen the h j k l keys for left, down, up and right and not the j k l ; keys? I type with ten fingers and with touch typing, the right hand is on the j k l ; keys. To go to left I have to switch my forefinger from the j to the h. I checked other national keyboards, they are almost all the same as the US keyboard. I noted that other software as well use the j and k keys to go down and go up. What is the reason for it? ps: I switched the keys h j k l to my j k l ; keys but I noted that other software use the j and k keys to move up and down so I switched back to default. I suppose that the up/down actions are much more frequent, down being the more frequent of those. Therefore, up got put on the strong finger and down right next to it. Then why weren't l and ; used for left and right? I would guess that since the pinky is so weak (then why is return there?) that it is much easier on the hands to put relatively unfrequent left all the way on the left and double up the index finger's job rather than force the pinky to work. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Combining normal commands and an exe in a map
Dalker on StackOverflow [1] recently helped me concoct this terrific exe for navigating xdebug traces: :exe '/^.\{'.(col(.)-1).'\}-'. Before I use it, I must 0f- to ensure that I am on the first dash of the line. I would like to map this all to the ` key (I use ' for marks) but I seem to have trouble combining the regular commands with the exe: nmap 0f-:exe '/^.\{'.(col(.)-1).'\}-' Obviously I am missing something, but all my googling turns up nothing. What keywords should I be googling, or what part of the fine manual should I be reading? Thanks. [1] http://stackoverflow.com/questions/8402412/vim-navigating-xdebug-traces -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Combining normal commands and an exe in a map
On Wed, Dec 7, 2011 at 19:01, Ben Fritz fritzophre...@gmail.com wrote: First, your mapping command is missing a left-hand-side. You need to tell Vim what you want to press to trigger your mapping. E.g. nmap F5 :echo 'foo'CR if you want to press the F5 key to echo the text foo on your screen. Second, since you're starting from normal mode, you need to finish off your ex command with a CR or the equivalent Enter. Remember mappings are telling Vim to execute each character basically as if you typed them in yourself. You need to press Enter to finish executing a search manually, so your mapping needs to do this as well. Two suggestions, however: 1. Use nnoremap instead of nmap to avoid accidentially triggering any mappings while executing your mapping. 2. Use an expression mapping, which would allow you to eliminate the exe altogether. See :help :map-expr. Thank you Ben. Interestingly, I had to move the cursor over two places, which is one more than I did when typing the commands by hand. Here is the final result: nnoremap F5 0f- :exe '/^.\{'.(col(.)-2).'\}-'CR I learned a lot from your post, especially regarding nnoremap. Thank you for your help! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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
Using Vim's :help feature to find keyboard shortcuts
I am trying to find a keyboard shortcut in VIM for inserting a new line below the cursor and moving to it, from Insert mode. Basically this would be ESCo so it would be easy to map, but I suspect that this handy shortcut must already exist (it does exist in IDEs such as Eclipse and Visual Studio). Assuming that it might be some modifier key (shift, ctrl, alt) and either Enter or O itself, I tried various combinations of :help ctrl-enter. This, in addition to experimentation and googling. The VIM help system tells me that it has no entry for ctrl-enter, and even though I found via google that Ctrl-o,o does what I want, the help text for Ctrl-o makes no mention of what this shortcut does in Insert mode. That, or I am using it wrong. Am I using the help wrong? Should the help text describe what the shortcut does in Insert mode too? Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using Vim's :help feature to find keyboard shortcuts
On Tue, Nov 22, 2011 at 19:43, Albin Olsson albin.ols...@gmail.com wrote: To find out what something does in insert mode, prepend it with i_ ie: :help i_CTRL-O I see, thanks! (On another note, it sounds like you are spending too much time in insert mode, remember: insert mode is just for entering text, and when you are done press esc. The vim-way of doing what you want to do, is to do as you already described it, just press o. Because normally, you should be in normal mode and not insert mode) My job is to spend time in insert mode :) Often I will end a line of code with the cursor in the middle of the line, due to closing all parenthesis as I open them, described here: http://dotancohen.com/howto/write_code.html That method has saved me innumerable headaches, syntax errors, and subtle bugs. But it means that simple Enter is just about useless. I suppose that I should probably map Ctrl-o,o to Enter, and regular enter to Ctrl-enter! Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: Using Vim's :help feature to find keyboard shortcuts
On Tue, Nov 22, 2011 at 21:03, Tim Chase v...@tim.thechases.com wrote: My job is to spend time in insert mode :) Only if all you ever do is insert text :) While I can only speak for myself, I spend a small fraction of my time actually inserting/changing text. The remainder of the time is spent on things like navigating the text, copying/moving/deleting/(in/de)denting text, reformatting, etc. By habit, I simply hit esc at the end of every insertion. Rarely does my next edit happen right where I left off. I do agree, my current project is in fact maintaining someone else's code. I did not realize that VIM would reformat code, now I have yet another thing to google this evening. Thanks! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: mapping ALT-backspace
On Wed, Nov 2, 2011 at 07:36, Tony Mechelynck antoine.mechely...@gmail.com wrote: In Normal mode, you should be able to use Shift-Left as a modifier to the d (delete) command, to delete [count] words leftwards, or the command daw (delete a word) to delete the word under the cursor (on both sides) and the white space on one side of it. See :help text-objects Tony, is there an alternative way to delete the previous word from Command mode. I often i^wesc but if I could save some keystrokes I would appreciate it. For that matter, what is the keyboard shortcut for going _back_ one word? Shift-Left is mapped by default to Previous Tab in Konsole, and I use that feature often enough to not want to change it. That said, I work on disparate servers (SSH) so I prefer to learn the 'right' VIM way as opposed to remapping when I can. Thanks. -- Dotan Cohen http://gibberish.co.il http://what-is-what.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: mapping ALT-backspace
On Sat, Nov 5, 2011 at 21:07, Tony Mechelynck antoine.mechely...@gmail.com wrote: Tony, is there an alternative way to delete the previous word from Command mode. I often i^wesc but if I could save some keystrokes I would appreciate it. For that matter, what is the keyboard shortcut for going _back_ one word? Shift-Left, as I said. Or, by looking it up (by :help S-Left without the quotes), you would have found b as a synonym. I did not realize would be how to look it up. The VIM help pages are very flexible in the input they will accept! Thanks. The rightest of the right Vim ways is to RTFM. Ouch, I deserved that! Thanks, Tony. Have a great week! -- Dotan Cohen http://gibberish.co.il http://what-is-what.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