Re: Profiling VIM and/or displaying current action
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? I don't know the answers to those two. I'd just like to give a suggestion (maybe you've tried it already in that case just ignore the following). 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. nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: open a file with a different path than specified
On Tue, Feb 24, 2009 at 6:05 PM, Samuel Ferencik wrote: > Basically, I am looking for a way (an autocmd, perhaps) to change the > path to the file being opened - before it is opened. I can determine > the physical path by an external (system) command. Suppose there is a > call "translate-path" and > translate-path MY_SOURCES:SETUP.COM > returns the string > PATH:[TO.MY.SCRIPTS]SETUP.COM > > I tried something like this: > autocmd BufReadPre *.* execute "e " . system("translate-path " . > expand("%")) > but I got > E201: *ReadPre autocommands must not change current buffer > > Do you see a way of doing this? As the autocommand does not allow changing the current buffer, an alternative is to *not* specify MY_SOURCES in your 'path' setting. Instead specify all the path that is defined in MY_SOURCES in your 'path', e.g: set path=.,PATH:[TO.MY.SOURCES],PATH:[TO.MY.HEADERS], and so on Otherwise define your own user defined command (:he user-commands) that will do the path mangling. nazri --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Insert mode completion for sentences
On Wed, Feb 25, 2009 at 2:59 AM, Tuomas Pyyhtiä wrote: > Any pointers to a script with an auto-completion feature that finishes > those whole sentences as well, or any other suggestions how I get this > done? Thanks! Use abbreviations. he :abbreviations example: :iab jas just another sentence nazri --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: open a file with a different path than specified
On Wed, Feb 25, 2009 at 7:33 PM, Samuel Ferencik wrote: > I will have to search on, I guess. In your original email you used BufReadPre autocommand. Try it with BufReadPost. It tried it here on my linux in my .vimrc: au BufReadPost test.txt e /tmp/test.txt And it seems to work (editing existing test.txt in any folder opens the file /tmp.txt). You can modify that to call your system command to get the wanted effect. nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Insert mode completion for sentences
On Thu, Feb 26, 2009 at 12:19 AM, Tuomas Pyyhtiä wrote: > Thanks for the suggestion. Although abbreviations are great, they don't get > the job done here as I would have to define and memorize 1 abbreviations > and that seems highly impractical. It seems to be that I am not alone with > this problem as some other user has commented (last comment) a similar case > here: http://vim.wikia.com/wiki/Dictionary_completions Hmm, maybe this will help: Whole line completion. :he i_CTRL-X_CTRL-L You can make an insert mode mapping to isolate the beginning portion of the phrase that you would like to complete, and then perform an i_CTRL-X_CTRL-L command on that. By isolate here I mean putting in on a single line of its own, otherwise the whole-line completion wouldn't work. This should give you a nice omni-completion window with the possible phrases to complete. Once you complete the phrase you may need to have another mapping to join/format the newly completed phrase into the previous sentence. You'll also need to make use of the 'complete' option to tell vim where to look for the 1 phrases that you have (all in one file, one line each). nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Pattern question: search for the last line of the same pattern
On Sat, Feb 28, 2009 at 3:28 AM, Sean wrote: > > idle -- line 1 > idle -- line 2 > if -- line 3 > if -- line 4 > if -- line 5 > iff -- line 6 > ill -- line 7 > > > What I want is two numbers with the pattern starting with "if": > (1) find the start line, 3 in this example > (2) find the end line, 5 in this example Another possible lead (as to other proposed ones) is to do a multiline search and put temporary markers for the beginning and end line which you can later process for getting the line numbers: %s/\(^if .*\n\)\+/\='BEGIN'.submatch(0).'END'/ nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: How do I go to the next non-blank character in the current column?
On Mon, Mar 16, 2009 at 12:40 AM, jw232 wrote: > > > Going either up or down See :he /\%c e.g: /\%9c[^ ] searches for anything that is not a space in the 9th column nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: How to automatically open a window when using tags?
On Mon, Apr 5, 2010 at 5:50 AM, Tony Mechelynck wrote: > Help windows all reuse the same window by design; but I suppose you could do > something like > > :noremap s That's a lot more keys than you'd actually need: ] Would achieve the same result. nazri. -- 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 To unsubscribe, reply using "remove me" as the subject.
Recover a deleted file from its swap file
I have a vim swap file for a file that I have just deleted. It is possible to get vim to (sort of) recover the content of the file referred to by the swap file? Thanks in advance for any help. nazri. -- 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: Recover a deleted file from its swap file
Thank you all for your enlightening responses. My problem is gone (it's was a PEBKAC). Here's what happened: I edited a file, typed something in, then decided that the file is better saved in a different directory so I moved the file to that other directory. I typed more stuff into the file and save it. I don't remember the exact steps I took to do the file move. Move forward a few hours later, I open the file in its new location and I only see the first content that I typed in before, not the latest! So I thought I must have made this mistake: 1. Edited a file, saved (without quitting vim). 2. In another terminal, *copied* the file to its new location. 3. Edited the file (in the same vim session), added more content, saved. 4. In that other terminal, I deleted the 'old' file. When I opened the file in its new location I see the old content. At this point my thought was *!#*!#&!...@w!y*!&. Then I remember that vim have a swap file and in that old directory there's exactly one swap file left over from some previous vim editing session. I created a new file with the same name as the file that the swap file is associated with but when I opened it in vim vim just created a new swapfile, 'ignoring' the old one. That's when I decided to ask the list. My attempts at using the :recover command failed (after creating a file with the same name as what the swap file is associated with) with a message saying that the swap file is broken. That was last Friday. Fast forward to today (Monday): Frustrated by this I decided enough is enough. I gotta handle it like a man: Don't fret over the lost bytes. So I proceeded with deleting the stale swap file. Then I go to the new directory where the file was moved to and opened the file and vim happily told me that a swap file exist for that file and when I choose recover *blam* the latest content of that file that I thought is gone forever is there, every single character! Heheh.. if that is not a case of PEBKAC then I don't know what is :) nazri. P/S: If you are curious the file contains usernames and passwords for "fake" gmail accounts to test out the web app in my $day_job. -- 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 7.3d ready for beta testing
On Fri, Aug 6, 2010 at 6:22 AM, Libo Song wrote: > I have an issue in the new Vim7.3e BETA. It is probably not a bug. > When I use :find, type some letters, then gives me a list of > choices. In 7.2, it shows, for example, the files under a dir. But in > 7.3e, it shows the files with the path, then fewer item on the list. > If I have a deep path, there will be no files shown, only a ">". > > BTW, how can I get to the next "set of items" show on the list other > than press the ? For example, I have the items shown: > aprutil.Makefile aprutil.gyp aprutil.target.mk gen/ include.target.mk > > I want to see more items. Try :set wildmode:list See :help 'wildmode' For details. nazri. -- 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, TCL, and TAG
On Wed, Oct 27, 2010 at 12:59 AM, a b wrote: > Hi, > > I'm having trouble using tag on tcl files in VIM. I have created the > tag > file in the base directory and it's there. I can do :tag tagname. But > I > can't use the ctrl-] shortcut to jump into tcl proc > > The problem is that in the files I'm working with, many proc are > defined > using namespace, so they have this format: ::ns_name::proc_name > > The tag file defines path for ::ns_name::proc_name, so it works > > but the ctrl-] shortcut, depending on the cursor placement, would only > search ns_name or proc_name, and so I get the tag not found error > message. > > Anyway around this? :help iskeyword nazri. -- 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: problem with map in custom vimrc
On Mon, Oct 25, 2010 at 10:43 PM, A Chaudhuri wrote: > I have a custom vimrc file with exactly this line: > > map :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) > > > When I call vim with -u pointed to the path of the custom vimrc, > pressing does not work. > > Output of first four lines of :map > > v "*d > n ihn :IHN > n is :IHS:A > n ih :IHS > :call libcallnr("gvimfullscreen.dll", > "ToggleFullScreen", 0) > > which shows that did get mapped. > > gvimfullscreen.dll is in C:\Program Files\Vim\vim73 folder, which > also contains gvim.exe. > I copied gvimfullscreen.dll to > > > I have the same line in the default _vimrc in my $HOME, and it works. > > How can I debug this? Change the definition of your mapping to do, say, ":echo 'hello'", and see if the problem is due to the mapping definition. nazri -- 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 off "end-id" type of abbreviation in Vim (insert mode)
On Mon, Oct 25, 2010 at 12:36 AM, Scott Steele wrote: > Because of how the "end-id" type of abbreviation is defined, this > problem doesn't exist for two-letter abbreviations, and I can still > use them (e.g. aa for always, bc for because). The single letter > abbreviations offer some of the greatest advantage in typing speed, > though, since many frequently used words are very short. (And I think > it would slow my typing down if I had to be constantly going back and > correcting whenever I noticed that I had preceded a single-letter > abbreviation with punctuation.) And I think I could get by without > having to use any end-id abbreviations. Since there are limited number of single-letter abbreviations, maybe you can have work-around similar to the following for those problematic cases: ia ``T ``The nazri -- 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 + unix shell + perl better than moder GUI IDEs like Eclipse or NetBeans ?
On Wed, Dec 17, 2008 at 10:39 PM, alex wrote: > - Unix + vim are better than GUI-IDEs or not in your eyes ? Absolutely, if you know what you're doing and you're a touch typist - can type without looking at the keyboard, ever. Mind you that's quite a big `if' there. The shell gives you a means to speed up the way you work exactly how you want it to be speeded up. Customize the shell so that your fingers do not have to leave the home rows at all while coding. That means never lifting your your hand to reach for the mouse; exploit your fingers' muscle memory to the maximum level possible which would result in faster editing plus full concentration on coding itself. I find that moving the mouse can be somewhat distracting at times as I have to set aside some brain activity resources for navigating the work area (haha). Your eyes focuses on an area the size of about a quarter, the area outside this are sort of blurred out. As you hunt around for that pixel that you want to click that focus area wanders on the screen which forces your brain to process whatever it is that you are seeing whether it is relevant to your coding or not. Using the mouse requires hand-eye coordination - more brain resources needed; while using the keyboard doesn't as you make use of your ingrained muscle memory. Your only focus on things that matter the most. This would include, among others, grokking the shell's programmable completion so that you can easily autocomplete your vim aliases based on the context. For example don't limit the filename completion to the files in your current directory. Make it attempt the completion on the relevant filenames in all the subdirectories of your project. Put vim -c "find $1" in say ~/bin/vif and make that vif's tab completion to search for those files in you project while filtering out files that you'd never touch. Add an alias, say 'vit' to vi -t and make it autocomplete to entries in from your tags file. I guess the main idea here is to focus on customizing the shell in order to automate away stuff that would slow you down when coding. nazri. P/S: Of course, there will always be trade-offs :) --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Bash-like tab completion
On Mon, Feb 9, 2009 at 3:52 PM, Per Thulin wrote: > > (1) Table like display of files... like in bash Try :find > (2) More careful suggestion of filenames so that I don't have to > backspace... like in bash :help wildignore nazri. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: don't want to type _
On Wed, Apr 4, 2012 at 9:49 AM, sinbad wrote: > imap does help, > it's not my emotion, it requires shift to enter _ or ->, > i tend to use my left little finger to press shift and lately > that finger is paining a lot, so i am finding ways to > avoid shift as much as possible. i'm so much used > to left finger, i'm not able to avoid even if i want to. > i am trying to use the right little finger, but it's not > happenin...:( The AutoComplPop plugin might alleviate your pain: http://www.vim.org/scripts/script.php?script_id=1879 it actively pops up an omni-completion box to match whatever it is you're currently typing with contents from the currently opened buffers. It's not perfect. I enable it in my vimrc all the time and sometimes it does get in the way , like preventing you from inserting the enter key the popup appears, but most of the time it's good at auto completing stuff_like_this. For -> you might find mapping "." to "->" in insert mode may help, or even ".." to "->". nazri -- 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
map that cross windows
Hi, When there are multiple windows open I'd like to be able to place marks that allow me to jump across windows. Say in window 1 I place the mark 'a' on some line and on window 2 I place the mark 'b', then from window 2 I can go directly to window 1 at mark 'a' without issuing window jumping command ([hkjl]) and jump to mark command ('[a-z] or `[a-z]). I'm aware that the marks [a-z] are file specific and the marks [A-Z] can cross files, but I'd like marks that can cross windows without loading a new file in the current window. Is there an existing way of doing this? If not ... for those who've got some time on their hands, and generous in their vim-fu: Could you write vim mappings that does this: m - place a window-global mark ' - got to a window-global mark Thanks! Nazri -- -- 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: unable to run cscope
On Tue, Mar 12, 2013 at 10:20 PM, FlashBurn wrote: > When I do that, I'm getting the following error: > E567: No cscope connections. I looked for help for E567 but it just shows me > help for cs-find. Has anybody encountered this problem before and managed to > fix it? You need to add a "cscope connection", like this: :cscope add /usr/local/cdb/cscope.out See :help cs for more examples. Nazri -- -- 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: redir and glob
On Tue, Mar 19, 2013 at 6:39 AM, FlashBurn wrote: > Obviously there is something wrong with the way I use redir and glob, > but I can't get my finger on it. Does anybody know what am I doing > wrong? To redir to the s:output_file variable do this: redir => s:output_file Also you may be able to simplify your BuildFileList() using globpath() instead: let files = globpath('dir1,dir2,dir3', '*.[ch]') nazri -- -- 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: Vim Lua and such
On Mon, Jul 8, 2013 at 12:03 AM, wrote: > The longest line of the dbfile is 71 characters long. So I think, at > least this is no problem ;) > > It seems to be a problem with one of the plugins. > Lua itsself read/interprets the dbfile without a second of delay, > though. > > I am not very motivated to step through all of my plugins switch them > off/on one by one... :-/ Using perf may help finding out where vim is spending most of the time on: 1. Edit Makefile and uncomment "#CFLAGS = -g" 2. Compile vim 3. in src dir: $ perf record ./vim -c 'set re=0' dbfile.lua 4. :q 5. perf annotate If you manage to get to step 5 then you'll be able to tell which function is taking the most time. Cheers, nazri -- -- 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: vim: toggle between tabs and toggle between buffers
On Fri, Dec 13, 2013 at 2:51 PM, ping song wrote: > I tried these pseudo-codes, but these are just 1 time thing and won't change > over time...couldn't figure out a good way. Use the '' argument to map to have a dynamic behavior: function NextBufferOrNextTab() if tabpagenr("$") > 1 return ":tabn " . g:lasttab . "\" else return ":bn\" endif endfun nnoremap ,l NextBufferOrNextTab() Untested of course :) I used similar method to have a dynamic map behavior for closing my buffers [1]. Nazri [1] quickquit.vim: https://gist.github.com/holygeek/7909458 -- -- 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: highlight items in red that are past due
On Tue, Jul 11, 2017 at 1:28 AM, Robert wrote: > I have a specific tag "due:-MM-DD" in my files. > > Is it possible for a function to compare all the matches it finds to today's > date and if the "due:" is is past, to highlight it? Your question can be simplified to "How do I highlight dates that are not today?" Vim regex supports what is known as "look behind" pattern - it is a pattern that tells the regex engine to register as positive match if the previous sequence of characters matches or does not match a given pattern. The following search pattern will match all the text "due:-MM-DD" in your file (not quite what you want, yet): due:[0-9]\{4}-[0-9][0-9]-[0-9][0-9] To tell the regex engine to exclude today's date use the negative look behind pattern \@!: due:\(2017-07-11\)\@![0-9]\{4}-[0-9][0-9]-[0-9][0-9] If you do a search using the above regex it will find all "due:" lines with dates that doesn't match 2017-07-11. To highlight the pattern you can put this in your .vimrc: syn match nottoday 'due:\(2017-07-11\)\@![0-9]\{4}-[0-9][0-9]-[0-9][0-9]' hi nottoday ctermfg=yellow guifg=yellow The next step is to automate the "today's date" part so that if you open the file again tomorrow it would exclude tomorrow's date, something like this should do it: function HighlightNotToday() exe "syn match nottoday 'due:\\(" . strftime("%Y-%m-%d") . "\\)\\@![0-9]\\{4}-[0-9][0-9]-[0-9][0-9]'" hi nottoday ctermfg=yellow guifg=yellow endfun nmap :call HighlightNotToday() nazri -- -- 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/d/optout.
Re: Vim surprisingly slow?
On Sun, Nov 12, 2017 at 10:21 PM, Tim Chase wrote: > If I change the "exec" to an "echo", it's as fast as I expect. > > Any idea what might be making the exec so slow? It's vim writing to disk that makes it slow. I ran it on SSD it's fast, on a spindle disk it's slow. I use fatrace[1] to see the file create/write/close operations done by vim. So vim is writing to the file for each line that matches the pattern. $ sudo fatrace ... vim(4719): WO /home/nazri/disk/20150425.txt vim(4719): W /home/nazri/disk/20150425.txt vim(4719): CW /home/nazri/disk/20150425.txt vim(4719): CW /home/nazri/disk/20150425.txt vim(4719): CO /home/nazri/disk vim(4719): WO /home/nazri/disk/20150425.txt vim(4719): W /home/nazri/disk/20150425.txt vim(4719): CW /home/nazri/disk/20150425.txt vim(4719): CW /home/nazri/disk/20150425.tx ... nazri [1] https://launchpad.net/fatrace https://github.com/truncs/fatrace -- -- 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/d/optout.