Vim cscope show results in split buffer - vim

I am looking to show the results of cscope in a split window. This question is the closet thing I found to an answerbut it doesn't explain fully how to resolve the issue.
I also found this question where in the comments section they explain how to use the cscope to get a split window. But I just get an error No matches found for the global symbol
I thought I would make myself clear. I want to view the cscope results like this:

You can use the quickfix window for this. See :h cscopequickfix.
I wrote a small plugin around this that makes the experience slightly better. For example, it doesn't jump automatically to first result, it maintains the splits layouts etc.
https://github.com/ronakg/quickr-cscope.vim

Related

How do I customize three letter sequences in Vim Latex-Suite?

I installed Latex-Suite for Vim, and I like it very much, but I'd like to be able to customize the environment mappings that came by default, and add new ones. For example I want to edit the equation environment that appears typing EEQ and move around some elements, like the \label{} command. How can I do this? I've been scanning everything inside my /usr/share/vim/vimfiles/ftplugin but I can't find a way to do it (or I just don't understand what those files are).
You want to check out the documentation on Macro Customisation, specifically the Tex_Env_{name} bit.
In short, if you want your theorem snippet to look like
\begin{theorem}
<++>
\end{theorem}<++>
then you want a line like
let g:Tex_Env_theorem = "\\begin{theorem}\<CR><++>\<CR>\\end{theorem}"
in your vimrc.
Note the backslashes to escape carriage-return, and double-backslash for normal backslashes.
The <F5> functionality (press F5 after typing an environment name, i.e. figure<F5>) should work out of the box, but you may need to refresh the three-letter code. This is more hassle than it needs to be, but something like
autocmd BufNewFile,BufRead *.tex call IMAP('EFI', g:Tex_Env_figure,'tex')
will do the job.
The answer to the question you asked comes with a caveat, which is that Latex-Suite is an enormous amount of code that is very hard and annoying to modify, and which does not play nicely with other plugins. This falls into Latex-Suite's philosophy that it's the only plugin you need for editing latex within vim.
That said, you want to look in /path/to/ftplugin/latex-suite/envmacros.vim. Searching for EEQ will lead you on the path to understanding the set of calls that latex-suite performs. I would like to reiterate that many functions are deeply intertwined.
On the other hand, there is a very easy way to have very easily customizable environments, which are snippets. See the UltiSnips page for a good example of how this works. These are designed for customization and extremely easy to write.

How to i show omnicomplete's autocomplete list without autocompleting current text

I am learning vim with omnicomplete. I am wondering whether I can show the omnicomplete list without autocompleting current text. For example,
If I type "str.c" and then invoke omnicomplete, it will show a list containing possible words starting with "c", and autocomplete the current text to, say "capitalize".
If, for example, the method I am looking for is count, I have to scroll all the way down the list to find it, or delete the "apitalize" part, and then type o, etc. Is it possible to just show the list, so that if I invoke it after c, it will show the list without autocompleting to capitalize? For example to something like below, where I can still type o to quickly go to count
Thanks to #romainl comment, I looked up completeopt, and I found the answer Make Vim completion popup menu work just like in an IDE. It has a bunch of other related tips. To make the behaviour as described in the question,
:set completeopt=longest,menuone
You can also just stick with the basic vim functionality, and use C-e while in completion to have vim remove the list and go back to the point you initiated the completion.
Alternatively, you can press <C-P> right after <C-X><C-O> to go back to what you typed while keeping the completion menu open.
Check out :h ins-completion-menu for more information.
I think that the initial problem was the lack of noinsert in completeopt option.

Table-of-contents with VIM folding

A long time ago there was an editor called MultiEdit. It has a feature which I can not find in all powerful VIM. In MultiEdit I could press some hot key and it would show something like table-of-contents (aka, condensed-mode, aka outline) were I could see only 1st line of all functions (let it be C source) in current file. I could then move cursor to function that I need and after pressing enter, mode will switch to normal and I would be in function that I need. Very useful for those who likes to put many functions in one file. This feature was extremely simple to use: one config option to enter regex for selecting title-lines and one hotkey for mode toggle.
VIM has folding. But this is different. Folding hides parts of files and displays folded-lines-indicator. It is much more difficult to specify what to hide in folds for table-of-content-display: you need to start fold at title-line and end before next title line. This is more complex than simple regex to select titles.
I so much wanted this feature, I even wrote VIM macro to emulate this MultiEdit behavior, even though I don't know VIM that much. I've wrote it in part because it was easier to to learn a new language and write a macro than to figure out VIM folding module complexity.
Unfortunately, after upgrading VIM, this macro now does not work (infinite loop?). I've wrote it long time ago, and what little I did know about VIM is all forgotten and I could not fix it now. (EDIT: I've fixed my script. Thanks to #romainl for the link).
My question is how to get this table-of-content like display in VIM?
This recent vimcast by Drew Neil explains the generalities of folding and this one goes through the process of creating the kind of folding you are (probably) after.
Depending on the language you work with and your coding style, something as simple as
set foldmethod=marker
set foldmarker={,}
and zM can get you a long way:
If you want to customize what information is displayed, the second link above is almost certainly just what you need.
Have a look at ctags and the vim plugin tagbar.
You also check out the vim plugin unite with the extension Unite-Ouline
it gives a behavior quite close to what you describe.
It's not great but have you tried setlocal foldmethod=syntax? It seems to do a decent job in 7.3 on Windows. ...although I just realized that our coding standard has the opening brace for a block at the end of the line rather than on a new line and if I change to having it on a new line it works substantially less well.

Using the quickfix window with vim+jslint

I'm using the vim+jslint combo described here, and am having problems figuring out how to use the two together. I'm guessing that the list of errors is supposed to show on the top half and the second half has the actual page? If so, how do I go about doing this? (Caution, I am completely new to the quickfix window, and the documentation isn't exactly the best at describing how to use it).
The quickfix documentation in the user manual section of Vim's help is good. You have to remember, that Vim's help has both a user manual and a reference manual. The latter is more terse.
The general run down is, after running :make the quickfix list is populated with anything the 'errorformat' option has been configured to parse. You use the :cn and :cN commands to move forward/backward through the quickfix list, respectively.
In the end I hacked the jslint script to output in the format for the quickfix window. I replaced:
//print((e.evidence||'').replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1"));print('');
with
print(a[0]+':'+e.line+':'+e.reason)
I think

TextMate's Jump to Function in VIM?

Recently I've been trying my hand at using vim instead of TextMate and one of the features that I've missed most in VIM is TextMate's jump to method function (CMD + Shift + T for those who don't know). From looking around I havn't seen any particular way to emulate this functionality and was wondering if anyone here has had experience with this sort of functionality in VIM.
Thanks in advance for any answers
Patrick
You're looking for vim's 'tags' functionality ... I answered a similar question about tags here: How to implement own tag jump in VIM with CTRL-]?
This functionality has been implemented in fuzzyfinder using :FufBufferTag. See the ticket
I'd love to hear good suggestions as I use Vim all the time but haven't used TextMate. I do the following things which slightly overlap.
Search for d-e-f-space-<first few letters of function name>. So to go to function foo (in Python or Ruby, and within the same file of course), I type /def fo and I'm there. I also have incremental search enabled in Vim.
Use marks for functions which I visit often. So I'll ma at the function definition and then 'a back to it later. I know it's not function definitions but it is a crutch.
you can create a tags file with ctags http://ctags.sourceforge.net/
basically $ctags -R
Then once you're in vim :set tags=/path/to/tagsfile
this will also be any tag so not just class names, methods, etc. In normal mode ctrl-] on the method/class/ and it will jump to that position.
You can also use the taglist plugin which will display current tags in a side window. ctags
I had pretty much the same problem and I found a quick and dirty solution (paste this in your .vimrc and call by typing :LS)
function! s:ListFunctions()
vimgrep /function/j %
copen
endfunction
command! -bar -narg=0 LS call s:ListFunctions()
If you require more functionality then Exuberant Ctags will do better for you
I'm using CommandT for file searching, then / to search for a particular function. However, the real issue is with CSS. Cmd Shift T in Textmate enable quick jumps to a particular CSS class, and that is a huge time-saver.
CTags doesn't support CSS parsing, unless you re-compile with a patch (found via google), but I'm not even sure if we can do fuzzy searching for CSS classes like in Textmate. I really miss the Cmd Shift T feature.
I've written a TextMate Bundle command (you can easily assign it to Ctrl+] for example) that lookup for the definition of the class or method under the caret and displays it in a tooltip, along with the file name and the line where it was find.
Check it out: Add a shortcut to TextMate to lookup a class or method definition in a tooltip
Hope you'll find it useful!
The feature described in this question has many different names depending on the IDE/Editor:
In Resharper it's called "Goto File member"
In Sublime Text 2 it's called "Goto Symbol"
In PyCharm it's called "Goto Symbol"
The feature is essentially the same though in all of the above implementations (and I assume it's very similar in TextMate as well). The feature brings up an interactive list of methods/functions (and potentially also includes member variables/properties).
The list allows interactive filtering by typing the name of a methods/functions/etc. The list also usually allows the use of arrow keys to select a method/function/etc. Hitting the enter key with a method/function/etc selected navigates to the line in the current file where the selected method/function/etc is defined.
Of all the existing answers in this question the only one that I see which seems to provide a reasonably similar implementation of this feature is to use the command:
:FufBufferTag
in vim's FuzzyFinder plugin.
The answer which suggests using the taglist plugin is not a good solution, because the functionality offered by the taglist plugin is quite different from the feature. The taglist plugin offers similar functionality - the ability to view an outline of methods in the currently file, but it does not offer an interactive way to filter that list in realtime. The taglist plugin does allow you to search the tag buffer, but that's not nearly as convenient as the "Goto symbol" functionality offered in other editors.
I wanted to provide an alternative suggestion here, which is to use the command:
:CtrlPBufTag
in the excellent Ctrlp vim plugin. In my opinion this by far the best implementation of the "Goto Symbol" feature currently available in vim.

Resources