Re: Do developers use vim exclusively or alternate with an IDE?
Some of the things that frustrate me the most in vim are: I've been using vim for almost 10 years and I'm still learning stuff all the time. Some of this might just be that you haven't found the things that make it easier for you yet. Copying and pasting text from outside of the editor. E.g. modifying an HTML page by swapping odd bits of text from another document. It just feels clunky to me and I often find myself using eclipse instead. You can make this easier by remapping the paste keys. Or having the clipboard be the default so you don't always have to type *p or +p. On the other hand, I usually find it easier to copy-paste whole sections into vim and then delete the things I don't want. Rather than just copying the things I do want. Ex commands and macros make it easier too. E.g. :','v/pattern/d, :s/../../g. If I have an class that I want to call a method of I generally like to know what the overloads are and the order of the parameters. I've got used to using intellisense in VS. I don't know if it just laziness that I would like it or if people normally require it or not. There are insert mode completion functions for html/css/php/java/c/etc. You can download some additional ones from vim.org if the defaults don't seem to work well for you. Lookup 'omnifunc' if you haven't already. Peeking at files real quick seems like a lot of work. Normally I do vsplit :o file.ext them Ctrl w w to change to the split, take a quick look and :q. This problem normally arises when browsing an unfamiliar repo. I have NERDtree but I don't think I'm using it enough. This is where the mouse and eclipse come in. I tend to move through a tree of files faster with a mouse. There's the preview window for that ':pedit filename' although I never actually use that specifically myself. You can use key commands like 'ctrl-w v' instead of vsplit, which makes it a little easier, and remap 'ctrl-w w' to something like 'tab'. If it's source code I highly recommend ctags, then use ctrl-] to jump to the function or class definition and ctrl-o to get back. If you have the filename you can use gf to go to the file (and ctrl-o to get back again). So basically, I've found that if something is annoying me, there's probably a way to fix it :) For what it's worth, when I started using vim I kept going back to other editors for html and java as well, but after a few years I got used to Vim enough that I just use it all the time now. Although, most of my editing is in languages that don't always have particularly good IDEs anyway. signature.asc Description: Digital signature
Re: Plans for Vim 7.4
On 2013-05-09 05:51, Bram Moolenaar wrote: Hello Vim users, We are now at patch level 7.3.931. In a few weeks we would reach 999. I don't want to find out what happens if we go over that, so it's time for Vim 7.4! How about the gvim port to GTK 3? I'll see if I can get that working if there's a chance it'll be merged. -- -- 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: Mapping for switching windows
On 2013-01-25 19:57, Adolfo Olivera wrote: Does anyone have some examples on mappings to switch windows faster *CTRL-W, h and CTRL-W, l* ? When I use win32 gvim I use: :map Alt+h C-Wh :map Alt+j C-Wj :map Alt+k C-Wk :map Alt+l C-Wl :map Alt+i gT :map Alt+o gt I also have alt+shift versions of each of those for moving windows and tabs rather than just focusing them. I also use the tab key to cycle through windows a lot, but this works best with only a couple splits. :map Tab C-WC-W When I use Linux, I have a real window manager and a real shell and those sorts of things, which means I don't need Vim's tabs and windows nearly as much as I do using win32. pgp3NxakbwEHH.pgp Description: PGP signature
Re: Remove spaces and line breaks and make single line wihtout spaces
On 2012-07-20 12:49, vicky b wrote: ... i want to have it as below all line merged as single line and no spaces at all ?xmlversion=1.0encoding=UTF-8?SupportItemItemInfo... You can select the text and use gJ, which acts like J but doesn't insert spaces between lines. It won't remove the in-line spaces or tabs hough. You can also use :%s/\_s// which removes all spaces and newlines. Do you really want '?xmlversion' though? That seems invalid, but I don't know why you're doing this so maybe I shouldn't question it. P.s. many of us cannot see the indentation in your email because our email clients do not support html formatting. pgpZXcZNl6maE.pgp Description: PGP signature
Re: sh (bash) syntax for here-document strings: embedding other languages
On 2011-12-19 14:00, Timothy Madden wrote: I find this everything-everyore-must-be-a-simple-RE design (for vim syntax highlighting) insufficient to describe the syntax of a language. More high-level features like followed-by, containing and contained regions should be present, but with the ability to add alternatives for the following and previous regions, to search only in a region as one would search in a file, to add names to any regions in order to search or extract data from it later or in other places, or to be used in some kind of group_exists('name') macro, and some other high-level conditionals, using defines or flags declared when matching regions of text like defining them from within the REs used for a match. For followed-by, containing, and contained, is that that just nextgroup and contained/contains/containedin? You can use nextgroup to do some of the stuff you want, but it's a bit of a hack (the keepend part of the hdBody line is important): unlet! b:current_syntax | syn include @awkSyntax syntax/awk.vim unlet! b:current_syntax | syn include @phpSyntax syntax/php.vim syn region hdBody matchgroup=shRedir contains=hdStart keepend \ start=-\?[']\?\z(.*\)[']\? end=\z1 syn match hdStart \%(.*\n\)\@= contained nextgroup=@hdLang syn cluster hdLang contains=hdAwk,hdPhp syn region hdAwk start=\%(.*\n\)\{0,4}.*ft=awk end=\#$ contained contains=@awksyntax syn region hdPhp start=\%(.*\n\)\{0,4}.*ft=php end=\#$ contained contains=@phpSyntax From :help syntax, Lexical highlighting might be a better name, but since everybody calls it syntax highlighting we'll stick with that. Lexical highlighting kind of defines the scope to simple regexes ;) There are also some advantages to keeping it in this scope, you might not always want a match to fail just because it's not technically valid.. syn-region is a good example of this, it's nice to have it highlight a string as a string even if you haven't typed the end quote yet. With a stricter parser you might get a syntax error and not have it match at all. That being said, I've wanted some higher-level features for the syntax matching too, and even more so for helping with indent expressions and omnicompleteion. I started writing a BNF like parser for vim a while back, but didn't get very far :( pgpovhf2lmwbe.pgp Description: PGP signature
Re: sh (bash) syntax for here-document strings: embedding other languages
On 2011-12-18 10:15, Timothy Madden wrote: The \z1 notation does not work for me no matter how much I try ... Only the first lines get highlighted (the lines matched by the start pattern in syn region ... start=+start_script...+ Other than those initial lines, I just get the original highlight from shHereDoc. I think you want to use a syn-region, you may want a matchgroup=shRedir to use the normal highlighting for the start and end patterns. sh_php_heredoc xxx match /\%(-\?\s*\(\|'\)\(\S\+\)\1\s*\%(.*\|\\\n\s*\)\n\)\@=\%(.*\n\)\{-,4}\%(\%(.*\s\+\)\?vim\?\|.*\S\+\s\+ex\):\s*\%(\%(\a\+\%(=[^\n\ s:]*\)\?:\)*\%(ft\|filetype\)=php\%(:\a\+\%(=[^\n\s:]*\)\?\)*\s*\|set\?\s\+\%(\a\+\%(=[^\n\s:]*\)\?\s\+\)*\%(ft\|filetype\)=php\%(\s\+\a\+\%(=[^\n\s:]*\)\?\) *\s*:.*\)$\_.\{0,}\%(^\t*\2$\)\@=/ contained keepend excludenl contains=@PHP containedin=shHereDoc Still, at run-time, the end expression \2, which should be the delimiter without the quotes, (\S\+, does not match the delimiter at the end of the here-document. Even if I try to get a shorter RE, still the backreferenced expesssion is not matched properly: \%(-\?\s*\(\|'\)\(\w\+\)\1\s*\%(.*\|\\\n\s*\)\n\)\@=\_.\{0,}\%(^\t*\2$\)\@= \%(-\?\s*\(\|'\)\(\w\+\)\1\s*\%(.*\|\\\n\s*\)\n\)\@=\_.\{0,}\%(^\t*\2$\)\@= Yikes, start with something even simpler than that until you get it working and then build it up from there. I wouldn't even try to script it yet. I have the following (and only the following) in my ~/.vim/after/sh.vim unlet b:current_syntax syn include @phpSyntax syntax/php.vim syn region shPhp matchgroup=shRedir contains=@phpSyntax \ start=+\z(.*\)\ze\n.*vim: ft=php+ end=+\z1+ And it highlights the following sh/php fragment correctly. php EOF ?php # vim: ft=php? ?php echo hi there; ? EOF Is it possible vim has a bug with regular expressions ? From :help \@= The part of the pattern after \@= and \@! are checked for a match first, thus things like \1 don't work to reference \(\) inside the preceding atom. It does work the other way around: pgpTZ84YZVjJ8.pgp Description: PGP signature
Re: sh (bash) syntax for here-document strings: embedding other languages
In a shell here-document there is no indication of the script language for the embedded document That's not necessarily true, I've done something similar and highlighted awk commands as awk from inside a shell script. The trick is that `awk' usually shows up on the command line so you can match that and make a guess that the string is an awk script, which works good enough for me. Using \@= helps with that from within syn-regions. For example: awk 'BEGIN { print hello, world }' Could be matched with something like: syn region shAwk start=+\v(awk.*)@='+ end=+'+ ... The wiki page with the tip also says (at the end) the highlighting does not end where it should, and I happen to run into exactly this bug. :( I think adding `keepend' to the syntax line might help with this. I also have another question: how do I make a syntax region that starts with a possibly-quoted identifier, like: script-\delimit'er' and ends with the /necessarily/ the same *un-quoted* identifier: script_delimiter Is there a way to express this with vim syntax highlighting commands ? You can use \z(\) and \z1 in a syn-region, but it probably won't support crazy quotations. I would just recommend not putting crazy quotations in your here document identifiers.. After all, you probably don't want to make vim a full-blown bash interpreter. Also, I would like to define a new syntax region that is contained in the shHereDoc group (already defined in syntax/sh.vim), and that: - start where the shHereDoc starts, if the shHereDoc starts with the exact text '# vi:ft=sh' as one of the first 4 lines - ends where the shHereDoc ends Can I express this with vim syntax highlighting ? You can do the `first 4 lines part' part using `\ze(\n.*){1,4}PATTERN'. I'm not sure about the best way to match the start of an existing group though. I would probably just copy the start= pattern from sh.vim, but there may be a better way. syn region shAwk start=+\v\z(.*)\ze(\n.*){1,4}vim:.*ft\=awk+ end=+\z1+ ... pgphmPsk03JxS.pgp Description: PGP signature
Re: gvim or vim in console...
On 2011-09-11, Kevin Tough wrote: I use Fedora and would like to know whether most programmers use vim from the console or do they/you use gvim. It probably doesn't matter too much which you use, but your question got me thinking, perhaps a little too hard, on why I use one over the other :) On Linux, I use the terminal version of vim. When I'm programming I usually work from the command line (using git, running make, etc) so it's more convenient to just have it in the same window and to be able to use ctrl-z/fg. Terminal vim also seems to integrate better with other programs. For instance, I use it to write commit messages, and to reply to emails from mutt. It also works over ssh and in screen. Terminal vim runs faster on my older computer too (faster font rendering or something). I have read that using one instance of vim is the best usage. I use multiple instances of vim, usually because I have multiple command prompts open. With a good window manager, it's easy to switch back and forth between them. On the other hand, when I have to use a certain other operating system, I tend to use a single instance of gvim.exe with many more tabs and split windows and more plugins such as NERD tree/taglist. Mostly to make up for all the things that the actual operating system doesn't handle very well.. pgpFAyRXHatXK.pgp Description: PGP signature
Re: 2html optimization
On 2011-06-15 08:36, Ben Fritz wrote: On my system, I have a ~/.vim/syntax/2html.vim, and also the default $VIMRUNTIME/syntax/2html.vim. When I use +runtime! syntax/2html.vim I see what you describe, as I would expect, because the '!' in the runtime command says source all files found. When I omit the '!' it works as intended, and only does a single conversion. Ah, that makes sense, I was unaware that runtime! would source all the files it finds. I have not tested 2html with Vim in ex mode. I would not be surprised if there are some problems with this. If it works, that's pretty cool! Do let me know if you see problems running 2html in ex mode, I imagine that might speed things up some. It works for me, I think i had to specify the TERM to get syntax highlighting to work. Without it and screen I sometimes get very simple highlighting but not the 256 color highlighting I want. For reference, the full command I use and the vimrc are posted here: -http://vpaste.net/index.cgi?ft=sh -http://vpaste.net/vimrc?ft=vim I notice that these references use the dynamic_folds option, but there are no folds in the document. See my note above, you could probably make this faster by setting the ignore_folding option! Folds aren't used by default, but you can add them. Same thing for some of the other settings, so I have to leave a lot of the 2html features turned on even if they're not used most of the time. For example: - http://vpaste.net/index.cgi?ft=sh,fdm=indent,number,expandtab I guess I could check the value of 'foldmethod' and if it's set to 'manual' I could set 'ignore_folding'. Some of these options I suggest above were added/augmented in later versions of the TOhtml plugin than you are using. I think that v9 is currently in the Hg repository, and I've given v10 to Bram, but you're still using v6 according to the meta tags in the generated output. Ok, I'll have to try updating sometime. Also note the html_use_encoding option takes an IANA name (i.e. UTF-8 rather than utf8). Perhaps I should add an auto-correction for that...I'll think about it. You could maybe add it to the help document. I missed the part about the equivalent html charset name. Using a real example such as UTF-8 instead of foobar might make it a little more obvious. pgpd8JHtYx4oC.pgp Description: PGP signature
Re: 2html optimization
On 2011-06-14 16:23, Benjamin Koltai wrote: I am currently using the command: HOME=#{ CONFIG.paths.lib_dir }/vimfiles/ vi -n -X '+runtime! syntax/2html.vim' '+xa' filename Using '+runtime! syntax/2html.vim' is acting funny on my computer. I haven't looked into it, but it's generating html for filename, and then generating another html for filename.html and calling that one filename.html.html.. Using '+runtime' instead of '+runtime!' or just using +TOhtml seems to fix it.. I tried -e but I do not get the syntax highlighting with that option. You can force ex to use syntax highlighting with a few tricks. You'll probably need to run it in screen if it's being run by a daemon, and you'll need to force the value of 'term' in vimrc. The gist of the command I use is: HOME=/home/andy screen -D -m ex -nXZ -i NONE -u vimrc '+sil! TOhtml' ... You can also speed it up a little but by using: let g:html_no_progress = 1 For reference, the full command I use and the vimrc are posted here: - http://vpaste.net/index.cgi?ft=sh - http://vpaste.net/vimrc?ft=vim If you find anything else that helps, let me know! pgpXyEyxL2w1S.pgp Description: PGP signature
Re: Inserting Line Numbers into Existing Text
On 2011-04-04 18:31, Daniel M. Eldridge wrote: While this works it fails to provide any context, therefore I want to insert the line number @ the beginning of each line and follow it with a tab and then have uniq ignore the first field with: uniq --skip-fields=1 It's not Vim related, but since you seem to be using Unix utilities to begin with, you might be interested in nl. nl -ba -nrz -w6 Actually, just plain nl will probably work because it uses a tab separator and 6 space padding by default, but the above command is a little closer to what you were asking for. pgpiuNKvV3XbP.pgp Description: PGP signature
Re: search and replace with word list
On 2011-03-02 14:29, Raleigh Rinehart wrote: Suppose I have in one file several lines (could be 100s of such lines) like this: .. Folder![CDATA[C:\work\sources\foo\bar\baz\MODULEX\lib]]/Folder .. Now in another file I have a list of words, in this instance separated by newlines, but could be changed to space/tab/comma/etc delimited. The number of words equals the number of lines that match from the first file. Now what I would like to do is to replace each occurrence of MODULEX in file1 with the corresponding word in file 2. By corresponding I mean if the lines (from file 1) and the words (from file 2) were both well ordered sets then the match is determined by the index into the set, or in other words a one-to-one correspondence. I think what I would do is paste the two files together side-by-side. You can do this in vim using visual-block mode, or if you're on a unix machine you could use the paste command. :%!paste file2.txt file1.txt or $ paste file2.txt file1.txt | vim - After that it's just a simple line-by-line substitution. You could even use sed if you wanted. :%s/\v(\w+)\t(.*)MODULEX/\2\1/ pgpH2ONBcodtC.pgp Description: PGP signature
Re: better browsing of IRC logs
On 2011-02-22 12:31, Adam Monsen wrote: I use irssi for IRC. I like to quickly browse (local) logs (in vim) sometimes before sending a message. I've got a rather clunky way of browsing them, and I'm fishing for ideas on how to improve the process. A while back I started a vim syntax file for IRC like logs.. There's not really any standard log format though, so it's full of horrible regular expression and could certainly be improved. Separating out different log formats would be a good start.. It works in most cases though, and with a little tweaking it appears to work on your example as well. Anyway, it does a search and tries to color each name uniquely, which I find quite helpful when browsing log files. It requires a 256-color terminal though and I haven't bothered to add support for GVim yet. Here's a TOhtml'd example from a recent trip to #vim: http://vpaste.net/Pb1Z6? I've attached the syntax file (vim license) if anyone's interested in using it and/or fixing all my buggy code ;) Functions and data for uniq looking names let b:names = [] function! Hash(str) let num = 0 for chr in split(a:str, '\zs') let num = (num+19+char2nr(chr)) % 216 endfor return num+16 endfunction function! DoName(name) if index(b:names, a:name) = 0 | return | endif call add(b:names, a:name) let key = substitute(a:name, '[^a-zA-Z0-9_@. ]', '', 'g') let ptrn = substitute(a:name, '[^a-zA-Z0-9_@. ]', '\\S\\?', 'g') let clr = Hash(key) exec 'syn match c'.clr.' \'.ptrn.'\' exec 'syn cluster ircNames add=c' . clr exec 'hi def c'.clr.' ctermfg=' . clr endfunction function! DoNames() for line in getline(0, '$') let name = matchstr(line, '\v([\(\[]?[0-9-]* *\d\d:\d\d(:\d\d)? *[APM]*[)\]]?|^)\s*(\[-+*@ ]?)?#?\zs[a-zA-Z0-9#|_@. \\]+\ze[:]\s', '\1', '') if name != '' call DoName(name) endif endfor endfunction Syntax syn match ircFile \v(\d{4}-\d{2}-\d{2}\.\d{6}([-+]\d{4}\u{3})?.txt:|^)he=e-1 nextgroup=ircDate syn match ircDate\v([\(\[]?[0-9-]* *\d\d:\d\d(:\d\d)? *[APM]*[)\]]?|^) contained skipwhite nextgroup=ircSys,ircSpeaker syn match ircSys \v(\w|\|-)+[^:]\s.* contained contains=@ircNames syn match ircSys \v^Conversation.* contained syn match ircSpeaker \v(\[-+*@ ]*)?[a-zA-Z0-9#|_@. ]+[:]\s contained skipwhite nextgroup=ircName contains=@ircNames syn match ircName\v[a-zA-Z0-9#|_@.]+:\s contained skipwhite nextgroup=ircName contains=@ircNames syn match ircURL \v(http://|.)\S+ syn cluster ircNames contains=NONE call DoNames() syn match ircIncr\w\+++ contains=@ircNames syn match ircDecr\w\+-- contains=@ircNames syn cluster ircColors contains=ircDecr,ircIncr Highlight hi def link ircFileType hi def link ircSys Comment hi def link ircDateNumber hi def link ircSpeaker Label hi def link ircNameIdentifier hi def link ircURL Tag hi def ircIncr ctermfg=green hi def ircDecr ctermfg=red let b:current_syntax = irc pgp8L9yK4mY02.pgp Description: PGP signature