Re: is the [Esc] key not very unreachable?
Nathan Huesken wrote: > - To me it feels like the [Esc] key would be very unreachable (for a > key which has to be pressed very often). How do other vim user cope with > this? I mapped Esc to CapsLock with xkbcomp as I never user CapsLock. Works great for me. The Gnome keyboard configurator can do this for you, too. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Use 'wrapmargin' to wrap visually?
Kristoffer Stensbo-Smidt wrote: > Hi vimmers! > > I often write assignments using Vim, so I like to use visual word wrapping > instead of hard breaking the line at a given text width. To do that I use: > > set formatoptions=l > set lbr > > However, when using a maximized GVim window (in the Gnome desktop) I often > see the last two or three characters in a line disappear behind the scroll > bar. I know this probably is a bug in Gnome and thus nothing has to do with > Vim, but it's still annoying. I can't see this behavior in GVim (Gnome), v 7.1.138 Maybe switching to a newer gvim version will remedy the problem? Alternatively, maybe using 'set fo-=t' instead of 'set fo=l' is enough. > So I was wondering if it there is something like 'set wrapmargin' that would > just visually word wrap a given number of characters from the windows > border? Or alternatively, visually word wrap at given text width? As far as I know, this is a longstanding wish that has not been implemented yet. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: can vim do this simple syntax translate
Andreas Bernauer wrote: > Sean wrote: >> For example, I have a text file in which >> there are a lot of expressions in the following form: >> >>id = number >> >> id: [a-z]+ >> number: [0-9]+ >> >> I want to rewrite these expressions into this form >> >> (set id number) >> >> is it possible to do this in vim? > The command you're looking for is > :s/\(\l\+\)\s*=\s*\(\d\+\)/(set \1 \2)/ Or, with less backslashes, using 'very magic' (the \v switch): :s/\v(\l+)\s*\=\s*(\d+)/(set \1 \2)/ -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: How to open and edit register in a window or buffer?
Ben Fritz wrote: > > > On Apr 19, 4:33 pm, Noah wrote: >> Is it possible to open a window with all >> the registers value listed and editable? >> Or is it possible to open a window that shows >> just one given register that I want to edit? >> I'm thinking of a special 'buftype' window >> like *cmdline-window except that when >> I run :wq the contents will be saved back >> into the register. This would be very handy >> for editing macros stored in registers. >> > > I don't know of such a thing...there may be a plugin though. Maybe 'tregisters'? http://www.vim.org/scripts/script.php?script_id=2017 Or 'clipbrd'? http://www.vim.org/scripts/script.php?script_id=1014 Haven't tried either, though. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: can vim do this simple syntax translate
Sean wrote: > For example, I have a text file in which > there are a lot of expressions in the following form: > >id = number > > id: [a-z]+ > number: [0-9]+ > > I want to rewrite these expressions into this form > > (set id number) > > is it possible to do this in vim? You may want to reaed :help pattern :help :s The command you're looking for is :s/\(\l\+\)\s*=\s*\(\d\+\)/(set \1 \2)/ You match the id '\(\l\+\)' and the number \(\d\+\), separated by the equal sign \s*=\s*, then replace it with (set \1 \2), where \1 \2 refer to the 'id' and 'number' matches enclodes in \(...\). -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Inserting characters like { in russian layout
netimen wrote: > Russian keyboard layout doesn't have many characters ({ [ < etc). I'd > like to map some other keys to it (preferably the numbers on the > right). > > Simple solution ":map 1 {" doesn't work, because I'd like the new > mapped key to behave as { in all modes. For example I'd like "f 1" to > jump to the next { character. You can solve this outside of vim, if your using a recent version of an X-Server: xkbcomp let's you change the keyboard layout with a shortcut. For example, I use a US Layout, but temporarily switch to a German layout to enter the umlauts. Recent distributions have a GUI where you can select the keyboard layout, otherwise http://www.xfree86.org/current/XKB-Config.html describes how to change the config files. Cheers, -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: :set nu -> how to copy lines with line numbers?
krzysztof cierpisz wrote: > when I mark in visual mode, only the text itself (what do we need > normally) is marked. > > sometimes I would like to select the interesting lines with the line > numbers from the left margin. > > how to copy them along with the text? One possibility: use :print (see :help :print) Select lines you want to copy, say ':print' and select the lines with your mouse, along with the line numbers. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Regex substitute only outside "strings"
ivan budiselic wrote: >>> So, for the line: >>> >>> 1234 a a "a" a >>> >>> I'd like to get: >>> >>> 1234 b b "a" b >>> >>> The question is, is this possible and how. >>> >>> What I've tried is >>> let line = substitute(line, '\([^\"]\{-}\)a', "\\1b", "g") >> >> ...because \{-} matches also 0 times; what you wanted is \{-1,}: >> >> let line = substitute('123 a "a" a', '\([^"]\{-1,}\)a', '\1b', 'g') >> > > Ok, this worked pretty well, except that it doesn't work for cases when > there's an 'a' at the start of the line (which I might be able to fix), and Allow matching 'start-of-line' (^) in front of 'a', too; see below. > the other problem which I wasn't specific enough about, and that is that I'd > like the change to happen to 'a's outside of strings, so for example > "xxxaxxx" shouldn't match. I guess this changes things quite a bit, sorry > for not being clear enough. So, would you like further help? If yes, could you provide an example for what you want to achieve? s/\(^\|\s\)\zsa\ze\s\?/b/ works for a 123 a a "axxx" a ==> b 123 b b "axxx" b -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Regex substitute only outside "strings"
ivan budiselic wrote: > Hi, > > I'll post a simplified version of my problem. Basically, I want to > substitute every occurrence of 'a' (the letter a, without the quotes) with > 'b', but only if 'a' is not inside a string, by which I mean it is not > enclosed in double quotes. > > So, for the line: > > 1234 a a "a" a > > I'd like to get: > > 1234 b b "a" b > > The question is, is this possible and how. > > What I've tried is > let line = substitute(line, '\([^\"]\{-}\)a', "\\1b", "g") You can use the \zs and \ze markers, which mark the beginning and end of the match to be substituted. :s/[^"]\zsa\ze[^"]\?/b/ An alternative is to use several substitutions: \ :s/"a"/xxx/ :s/a/b/ :s/xxx/"a" Provided, xxx does not appear in your text. > There are a few obvious problems with this. First off, I'm not sure whether > the \ before the " is necessary (Vim regex syntax is unfortunately sort of > idiosyncratic), but in any case, neither version works. The output I get for > the previous line is: > 1234 b b "b" b ...because \{-} matches also 0 times; what you wanted is \{-1,}: let line = substitute('123 a "a" a', '\([^"]\{-1,}\)a', '\1b', 'g') (which does what you want; btw, note that the double quote '"' is not quoted). See :help /\{- :help \zs > Also, the above code in no way addresses the part "behind" the strings. In your example it does, though? Cheers, -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: vim leaves zombies behind
John Little wrote: > On Mar 16, 12:58 am, Spiros wrote: :%! some_executable the executable becomes a zombie after it terminates and remains a zombie until I exit vim. >> Ubuntu GNU/Linux. >> The version from the /var/lib/dpkg/status file is >> Version: 1:7.0-035+1ubuntu5 > > That's the version, 7.0.135, in Ubuntu 8.04, aka Hardy, and is quite > old now (October 2006). Hardy can be updated to 8.04.2. It has vim 7.1.138, where I don't see the problem. Besides, I don't see the problem on SunOS 5.8 with a vim 6.3. So maybe there is some other reason but vim? -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Going to the beginning of a line in command mode
Per Thulin wrote: > Hi dear list of fellow vim users, I wanted to remap some keys: > > cm > cm > cm > > But now goes one character to the left! Can I set directly > to the command to go to the beginning of the line? Use :cnoremap instead of :cmap This avoids the mapping to be reinterpreted again as . -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: How does CTRL-T and CTRL-O work?
Foss User wrote: > As you can see if I mix CTRL-O and CTRL-T, it becomes difficult for me > to predict the behavior. It is easy to understand where I am going to > move next if I press CTRL-T by using the :jumps command. But I don't > seem to understand why when I press CTRL-T suddenly it moves forward > to some unpredictable place. Ctrl-O and Ctrl-T use different stacks, as they relate to different concepts, namely jumps and tags. As you already mentioned, Ctrl-O uses the jump list, visible with the :jumps command, the list of places where you have been. Ctrl-T uses the tag stack, visible with the :tags command, the list of places from where you jumped to a tag (eg. with Ctrl-]). So, if you use Ctrl-O, it goes back where you came from. If you use Ctrl-T, it goes back from where you jumped to a tag the last time. What might have confused you is that jumping to a tag (Ctrl-]) updates both the jump list (as you leave your current position) and the tag list (as you jump to a tag), but Ctrl-O does not update the tag stack, nor does Ctrl-T update the jump list. That's why you 'jump forward' if you first use several Ctrl-O and then Ctrl-T: the Ctrl-O updated the jump list, but left the tag stack as-is. See :help tag-stack and :help jump-motions (which mentions ':tag'). > Also, is there > a list of jumps that CTRL-T would take me through that I can see by > using a command similar to :jumps? :tags -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: lcd makes my session files unusable (bug?)
Ben Fritz wrote: > On Feb 26, 2:55 am, Andreas Bernauer wrote: >> fka...@googlemail.com wrote: >>> It seems that if lcd is used, the paths in the session files are not >>> set correctly anymore. >> It looks like this bug was introduced with 7.2.055. >> The attached patch against 7.2.127 seems to fix this. > > Will this also fix session behavior when 'autochdir' is set? I don't > currently have a setup to build Vim, or I'd try it myself. I suspect > the issue is similar if it isn't the same one. I don't understand what you mean. The following :set autochdir :ed subdir/text.txt :mks! ~/Session.vim-7.2 :qa is creating a valid session file (with vim 7.2.127), even without my patch. Can you give an example of what is not working but could with my patch? -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: lcd makes my session files unusable (bug?)
fka...@googlemail.com wrote: > It seems that if lcd is used, the paths in the session files are not > set correctly anymore. > I use 7.2.108 (gentoo-linux) and have not had this behaviour in 7.2. > > Try this to reproduce: > > * rm ~/.viminfo ~/.vimrc > * vim --noplugin > * :ed ~/subfolder/test.txt > * :lcd ~/subfolder/. > * :mks! ~/sess-test.vim > * :qa > * vim --noplugin -S sess-test.vim > > Result: vim does not open ~/subfolder/test.txt but test.txt (which > does not exist). > This does not happen if lcd (see above) is not called. It looks like this bug was introduced with 7.2.055. The attached patch against 7.2.127 seems to fix this. I wanted to CC vim-dev, but my email does not seem to come through, so I'll post on vim-dev separately. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~--- Problem: Saving a session file ignores changes in the cwd of a buffer. Solution: Check for correct return code of mch_chdir. diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 60bbb5f..c730d76 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8792,7 +8792,7 @@ ex_mkrc(eap) else if (*dirnow != NUL && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) { - if (mch_chdir((char *)globaldir) == OK) + if (mch_chdir((char *)globaldir) == 0) shorten_fnames(TRUE); }
Re: External compiler linking in vim
Abhi wrote: > Hi, > I want to enable compile feature of modelsim tool in Gvim . Please > guide me in this regard as how any external compiler is linked to vim > editor? I'm not sure if I understood you correctly, but if you want to call some compiler from within vim and collect its errors, you can use the :make command. :make usually calls the 'make' program, but this can be set with the makeprg option. See :help make_makeprg for details -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: lcd makes my session files unusable (bug?)
fka...@googlemail.com wrote: > It seems that if lcd is used, the paths in the session files are not > set correctly anymore. > I use 7.2.108 (gentoo-linux) and have not had this behaviour in 7.2. > > Try this to reproduce: > > * rm ~/.viminfo ~/.vimrc > * vim --noplugin > * :ed ~/subfolder/test.txt > * :lcd ~/subfolder/. > * :mks! ~/sess-test.vim > * :qa > * vim --noplugin -S sess-test.vim > > Result: vim does not open ~/subfolder/test.txt but test.txt (which > does not exist). > This does not happen if lcd (see above) is not called. It looks like this bug was introduced with 7.2.055. The attached patch against 7.2.127 seems to fix this. I CC vim-dev to include the patch. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~--- Problem: Saving a session file ignores changes in the cwd of a buffer. Solution: Check for correct return code of mch_chdir. diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 60bbb5f..c730d76 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8792,7 +8792,7 @@ ex_mkrc(eap) else if (*dirnow != NUL && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) { - if (mch_chdir((char *)globaldir) == OK) + if (mch_chdir((char *)globaldir) == 0) shorten_fnames(TRUE); }
Re: How to do operations on selections ?
Lenin Lee wrote: > I also need to get the line number of the first line belongs to the > selection area and the last one, is there a way to do so ? line() accepts a mark, and the marks '< and '> point to the beginning and end of a selection: let start_sel = line("'<") let end_sel = line("'>") Note that user-defined commands can take the current range as a parameter, see :help command-range. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Making Vim as Default Editor for Unix's INFO
Gundala Viswanath wrote: > Is there a way to do it? > Because now it is set to Emacs. > > I tried set path to EDITOR =/usr/bin/vim, > however without any effect. Try 'info --vi-keys' info does not use emacs to show the info, just something that looks like emacs. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Profiling VIM and/or displaying current action
Nazri Ramliy wrote: > On Sun, Feb 22, 2009 at 11:59 PM, WL wrote: >> 1. Is there a way to profile VIM so that I could find the culprit >> script or .vimrc line? >> >> 2. Does VIM support a way to display the action its currently doing or >> give some kind of feedback that its still alive when performing time >> consuming tasks? > > Run strace on vim on another terminal and as soon as that problem > happens see what's up in that strace output. It might give a clue. You could also attach gdb to the vim process and check the backtrace. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Highlight whole line if keyword is not there
krabu wrote: > I need to highlight lines in grey text color, if there is not the keyword > "column" OR if there is the keyword "noshow". I want the whole line to be > affected, but the keywords are not at the beginning of the line. One way to do it: Add two highlight groups RegularLine, GreyLine: :hilight RegularLine ctermbg=yellow :hilight GreyLine ctermbg=grey Add matches for the line you want, using priorities " default: everything is GreyLine :call matchadd("GreyLine", "^.*$", 5) " ...except when 'column' appears anywhere on the line :call matchadd("RegularLine, "^.*column.*$", 6) " if 'noshow' is anywhere on the line, always stay GreyLine :call matchadd("GreyLine, "^.noshow.$", 7) This uses the priorities 5-7 to overrule previous matches. In the following lines, only the line marked with (*) is RegularLine, all other lines are GreyLine line1 line2 column (*) line3 column noshow line1 is GreyLine, because there is no 'column' line2 is RegularLine, because there is 'column' line3 is GreyLine, because 'noshow' is on that line > Another thing: is it possible to fold the affected lines? Not directly from the matches AFAIK, but you can write a fold expression: :set foldmethod=expr :set foldexpr=getline(v:lnum)=~'.*noshow.*'?1:(getline(v:lnum)=~'.*column.*'?0:1) This will put every line that contains 'noshow' or not the keyword 'column' on foldlevel 1, otherwise (keyword 'column' present, but not 'noshow') on foldlevel 0 (='not on a fold'). :set foldlevel=0 will fold the grey lines away. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: hjkl-ing while in insert mode
Tony Mechelynck wrote: > In fact, the following > > :inoremap > :inoremap > :inoremap > > create an undo point after each WORD. Alternatively to , you could use u, which breaks an undo sequence and does not move the pointer. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: how to set background color from the minibuffer , and how to cancel the gui tabs in win
Meir Yanovich wrote: > Hi > Thanks for the fast reply > the first one working great but the second one with the Tabs does not work > at all > it still opens me the GUI tabs version > what im i doing wrong here ? I think, he meant :se go-=e for the tabs. see :help 'go' -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: folding of patch files
Tim Chase wrote: > For a more complex version, you could use > > fde=(getline(v:lnum)=~'^Index')?0:(getline(v:lnum)=~'^=\\{3,}')?1:((getline(v:lnum)=~'^@@')?'>2':'=') > > (all in one line, in case mailers mung it) which should handle > both multiple hunks and multiple files-to-be-patched in the same > .diff/.patch file. > > That breaks down as > > - If it begins with 'Index', don't indent it > > - If it begins with 3+ "=" signs, start indenting 1 level > > - If it starts with "@@", consider it the beginning of a hunk and > start indent-level-2 > > - Finally, for everything else, treat it as the indentation that > comes from the previous line. Thank you for your input. I used it as inspiration for the attached 'diff' ftplugin, which handles the fold level of various diff formats (normal, context, unified, subversion, git, rcs, ed). -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~--- setlocal fdm=expr setlocal fde=DiffFoldLevel() setlocal fdc=1 " Get fold level for diff mode " Works with normal, context, unified, rcs, ed, subversion and git diffs. " For rcs diffs, folds only files (rcs has no hunks in the common sense) " fdl=1 ==> file " fld=2 ==> hunk " context diffs need special treatment, as hunks are defined " via context (after '***'); checking for '*** ' " or ('--- ') only does not work, as the file lines have the " same marker. " Inspired by Tim Chase. function! DiffFoldLevel() let l:line=getline(v:lnum) if l:line =~# '^\(diff\|Index\)'" file return '>1' elseif l:line =~# '^\(@@\|\d\)' " hunk return '>2' elseif l:line =~# '^\*\*\* \d\+,\d\+ \*\*\*\*$' " context: file1 return '>2' elseif l:line =~# '^--- \d\+,\d\+ $'" context: file2 return '>2' else return '=' endif endfunction
Re: Is it possible for the vim tag system to distinguish between functions with the same name but different signatures?
poireau wrote: > I'm currently using vim with exuberant ctags and I love it, except for one > thing: if I have to functions named foo, say foo(int) and foo(), vim does > not make any distinction between them and jumps to one of them randomly when > C-] is pressed. > > Is there a way to make vim more intelligent? I'm open to using something > else than ctags, as long as it works better :) You could consider cscope http://cscope.sourceforge.net/ Works great for me. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
folding of patch files
Is there a built-in folding method for patch files? When I open a patch file, I would like to be able to open and close individual hunks as well as all hunks of a single file. Isn't there something built-in? (I know I could write my own fold-expr.) I tried all foldmethods (syntax, indent, etc.), but none worked. I looked around in the help about diffs and folding, to no avail. Thank you. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
folding of patch files
Is there a built-in folding method for patch files? When I open a patch file, I would like to be able to open and close individual hunks as well as all hunks of a single file. Isn't there something built-in? (I know I could write my own fold-expr.) I tried all foldmethods (syntax, indent, etc.), but none worked. I looked around in the help about diffs and folding, to no avail. Thank you. -- Andreas. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---