I am using shortcuts of cscope in vim editor as per http://cscope.sourceforge.net/cscope_vim_tutorial.html
Shortcuts are not showing all results of the search but it is directly moving to one of the results.
At the end it goes to a specific result from the search and shows below result if I searched for my_func using shortcut:
(1 of 6): <<>> * my_func:
Can anyone please let me know how to show all the results as the result of cscope shortcut in vim editor.
All results are available in the Quickfix Window.
Type :cope to open the Quickfix Window.
There you will find all your results. Navigate over them with normal Vim movement. <ENTER> jumps to the result.
I have tried the tutorial here: Vim/Cscope tutorial. After changing the #'s in the cscope_maps.vim file to SPACE I got Ctrl-SPACE s to launch cscope in gVim. However, it takes over the whole window rather than splitting the window for the cscope info.
I then tried as suggested in the comments to the cscope_maps.vim file changing nmap <C-SPACE>s :scs find s <C-R>=expand("<cword>")<CR><CR> to nmap <C-SPACE>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR> because it appears that my gVim does nto support the :scs command. However, this still displays the cscope info in a full window, blocking out my code. When I exit the cscope interface, I return to two split screens.
Any help on how to craft a command in gVim 7.3 that will launch cscope in a split window?
scscope find c foo does what it's supposed to do: display a list of functions calling foo in the command line and open the chosen one in an horizontal split.
But that is not what you want, is it?
The list of possible targets is always displayed in the command line which is expanded as needed: it can't be displayed in a window at all.
That said, you can use the quickfix window to display the list instead of the command line, see :help cscope-options.
I'm using vim-rubytest to execute tests from within MacVim.
This prints output in vim's command output window.
The problems are that this output is not scrollable or disappears after i switch to editor.
Is it possible to send this output to separate tab/window in Vim?
I don't use vim-rubytest plugin but looking at the documentation it seems to me that by default vim-rubytest will put the contents into the quickfix list. To open the quickfix window issue the following command:
:copen
You can navigate the quickfix list via :cnext and :cprevious.
I belive the quickfix approach to be the preferred way, but to answer you question you can redirect the output into a register and then paste into a new buffer.
:redir #"
Then execute <leader>T. watch it all go by. Then end the redirection and create a new buffer with the contents inside.
:redir END
:new|pu|0d_
For more help see
:h quickfix
:h :cnext
:h :redir
:h :new
:h :put
:h :delete
The default on vim-rubytest is for let g:rubytest_in_quickfix = 0 this will execute everything on the terminal and echo the results.
In order to "open in a new window" you should set
let g:rubytest_in_quickfix = 1 and then the output will be run and applied to the quickfix. This will open up a separate quickfix window that you can use see all the failures and allow you to jump to the file.
There is an issue with the usage of quickfix that I have filed on github (Reference) that doesn't allow you to open the first error. In the issue I posted a possible fix and have my own fork with it applied + some other minor adjustments to make using quickfix more ideal in my own TDD workflow.
After I run a grep search in vim with :grep, I get a list of files. Is there a way to select one of those files and open it in a new tab at that particular line?
Just for completeness, as well as the :copen command, there's also :cw, which only opens the "quickfix" window if there are entries (so if your grep has no results, it won't appear).
I think the easiest way (without defining a mapping) of making the files open in a new tab would be to do:
:cw " Open the quickfix window
Ctrl-W T " Switch the window into a new tab
<ENTER> " Open the file/line
Alternatively, you could do:
:cw " Open the quick fix window
Ctrl-W <ENTER> " Open the file/line in a new window
Ctrl-W T " Move the new window to a new tab
If you want to do it by default, you could probably use the BufEnter and BufLeave autocmds to create and remove a mapping when entering and leaving the quickfix window; however, this is probably not trivial.
:help :cw
:help :copen
:help quickfix
For achieving what you want you have to open the quickfix/error window after calling grep:
:copen
I have a script that makes it for me every time i use grep.
I came upon this thread looking for an answer to a very similar question. The answer presented above, though correct, failed to describe a convenient way to open ALL the files in the QuickFix window at once ... into either buffers or tabs.
There doesn't seem to be a built in command to do it, but it's trivial as a VIM plugin ... somebody has done it here
http://pastebin.com/J9RwciFQ
It's 12 lines of code (one function) ... pasted here to save you a click during your analysis. Do follow the pastebin link if you are going to try to implement this though ... my plugin is installed in pathogen directory and I modified the plugin from the original slightly (details after code).
~/.v/b/v/p/quickfixopenall.vim
" Create command
command! QuickFixOpenAll :call StartQuickFixOpenAll()
function! StartQuickFixOpenAll()
if empty(getqflist())
return
endif
let s:prev_val = ""
for d in getqflist()
let s:curr_val = bufname(d.bufnr)
if (s:curr_val != s:prev_val)
exec "edit " . s:curr_val
endif
let s:prev_val = s:curr_val
endfor
endfunction
So once I have a grep result I'm satisfied with ... the plugin has a function :QuickFixOpenAll ... I had to modify the plugin as given (added the following line to the quickfixplugin.vim). And I renamed his given function StartQuickFixOpenAll ...
" Create command
command! QuickFixOpenAll :call StartQuickFixOpenAll()
Then you have all the files in the grep result open as buffers ... if you want to run any commeon operations such as find/replace you can prefix the regular command with the "bufdo" command which will perform your command in all ... in VIM type "help bufdo"
You can fairly trivially modify this plugin if you wan to use tabs ... it uses the commaned "edit" ... just replace that with "tabe" and :QuickFixOpenAll will open each result buffer in a new tab.
If you get a list of files you can browse them in a tree-like manner via
:cn
:colder
For more information
:help grep
and scroll to the bottom of the entry
I'm a pretty new Vim user and I've found that its learning curve is quite steep (at least for me). I just installed this vim script for JavaScriptLint error checking, which shows errors in vim's quickfix window once I save a buffer.
However, I don't know what to do next.. How do I 'scroll' through all the errors? How do I close the quickfix 'window'? How do I get it to check for errors after I've made changes to my code?
I've looked at the vim quickfix docs but the amount of commands are overwhelming and I can't seem to find what I want. Any help would be appreciated.
A side question: is there any way to have javascriptlint check for js errors for code residing in a .html file?
There are a lot of commands for quickfix as you have said, but I tend to find I only use a small subset of them:
:copen " Open the quickfix window
:ccl " Close it
:cw " Open it if there are "errors", close it otherwise (some people prefer this)
:cn " Go to the next error in the window
:cp " Go to the previous error in the window
:cnf " Go to the first error in the next file
:.cc " Go to error under cursor (if cursor is in quickfix window)
I tend to use this with :make and :vimgrep, so I can't comment on the Javascript lint checker, but this should give you something to get started.
Regarding the general use of JavascriptLint, I'm not a javascript programmer, but it looks like the script exposes a function called "JavascriptLint", so if you want to call it manually, you can use :call JavascriptLint(). However, it works on the disk copy of the file, so it'll have to be saved first. If (and only if) the command line jsl works on html files, you should be able to use :call JavascriptLint() on an html file to check the internal javascript. You could also do:
autocmd BufWritePost,FileWritePost *.html call JavascriptLint()
to automate it. If jsl doesn't support html files, then (short of patching the application or asking the author to change it), it's probably a lost cause...
The easiest way to navigate the quickfix list (or the location list, for that matter) is the unimpaired plugin.
Once the quickfix window is populated, [q and ]q go forward and back (respectively) in the quickfix list. [Q and ]Q go to the beginning and end (which is especially handy if you only have one item in the list; this makes vim complain about [q and ]q). So the workflow is:
Run whatever command populates the quickfix list
Type [Q to go to the first item
Scroll through subsequent items (if any) with [q and ]q
If you're using Syntastic, you'll get the location list instead of the quickfix list. No problem; just use [L, ]L, [l, and ]l in the same way.
unimpaired has loads of other handy mappings too -- [e and ]e "bubble" lines up and down, [<Space> and ]<Space> insert blank lines above and below, etc. I was surprised nobody mentioned it here before; that's probably because it didn't exist until January 2010, though the question was asked in 2009.
Put the following two lines in your .vimrc file:
map <C-j> :cn<CR>
map <C-k> :cp<CR>
Now you can navigate through the errors using ctrl-j and ctrl-k, which mimics the standard down and up motion commands j and k.
You can also use :cc 2 (or any other number) to jump to, in this case, the second error in the quickfix window. Navigating with :cn, :cc 4, etc will put the cursor on the line in question.
In addition to #DrAl's great answer about how to open and close the quick window and navigate between entries, I made an image to show some of the other quick fix navigation commands.
Each group of 3 files below represents a set of quickfix results, e.g. from a vimgrep. cnewer and colder are for going through historic result sets.
Maybe this option didn't exist when this question was written (or maybe I'm embarrassing myself because there's something in my .vimrc that makes this happen) but when I get a Quickfix List, I just navigate it with j and k then hit <CR> (i.e. the Enter key) to jump to that place in the file.
Then, to get back to the Quickfix List I type Ctrl+W j for "move down a window" and I'm back.
Finally, when I'm done, I just type :q, like I would to close any normal window.
The best-practice way of integrating JavaScript syntax-checking is using the Syntastic Vim plugin, which is using Vim's location-list (which is parallel to the quickfix) window.
I've written answers for this question and this question explaining how to do it, plus also how to get source-code browsing / tag-list for Vim using the community-driven jshint.com (which is way better than JSLint IMO) and Mozilla's DoctorJS (formerly jsctags).
the quickfix window is operated mostly like any other vim window: j down a line, k up a line, :cn to jump to the next error/warning, etc.
experiment!
Although this requires > Vim 7.4.858, the cdo (or ldo for location lists) command allows updating a non-contiguous set of lines in a way you could once only do with sed:
:vimgrep /re/ %:p
:cdo! norm #a
# or
:cdo! s/re/repl/
The above shows running a recorded macro or a simple search and replace. Missing seems to a be a way to pipe through and external command as you can with :range! command