Vim, constantly displaying args list - vim

I found that arguments list is more useful than buffers list. With vim-airline plugin you can see all current buffers in the topbar. I wonder if there is a similar plugin or function to always display argument list? It would be useful if it could work together with vim-airline.

No, this is a bad idea. The argument list is frequently used for mass-editing many (hundreds) of files, and those wouldn't fit anywhere in the UI. That's why I'm also no fan of permanently displaying the buffer list. [1]
With tabs, windows, and buffers (and dozens of related commands), Vim has very powerful means to deal with multiple files. Each person's workflow is unique; you need to find your very own, personal one by learning the available commands (the :help is very comprehensive), and trying out different approaches.
[1] From a functional standpoint, buffer and argument lists actually are very similar. Both can be added to, removed from, and used for mass operations. It's only that the adding to the buffer list is done automatically.

Related

vim lookup struct elements/members

Does anyone know of a vim plugin that allows to look up struct members/elements of structures in C or classes in case of C++?
I'm thinking something similar to jumping to a definition of a struct using cscope/ctags, but ideally I would want something similar to moving a cursor over the desired variable and a keystroke will pull up a table akin to when you use omni-complete?
I've been trying to find something but to no avail.
The requirement is: should be exclusively for vim.
99% of my development is sshing to a remote linux machine.
Normally my workflow is, git clone the project, setup ctags and cscope, open up the desired file and load up my cscope db and that's where I stay for the majority of the day, moving around the directory I have the nerd-tree plugin.
So far I use a combination of ctags/cscope, and calltree plugins to look up function callees.
I'm missing a plugin that allows me to simply look up struct elements.
I don't really use omnicompletion because it is notoriously slow and I've given up to make it faster.
Any ideas?
With universal-ctags, given you've used the right options, you can always obtain the members of a class/struct type.
If you read in between the lines, this means there is no efficient way to do it on a C++ variable if you stick to vimscript. I've tried do it, but I've given up on this path eventually ; path that has no way to support auto.
Now, I've started using (/implementing) another approach to analyse C++ code and exploit the information from vim: I rely on libclang. The catch is that it needs to operate on the current translation unit (TU), and if the TU is long (e.g if it includes many long files), it's takes time to parse it for the first time since the last time it has changed (I expect the solution to change with C++20 modules) -- the analysing is done on demand, and not in the background. Note: my plugin is currently under development and I haven't yet provided an high level Vim function that returns the type of a variable and its associated information (type, members, possible enum values...)
If your ultimate objective is completion of members, clang based tools provide a dedicated API for this purpose that'll be more efficient than completely analysing the current TU. The plugins you don't wish to use exploit this API. LSP servers even try to cache as much information as possible (for navigation and completion purpose only).
Note that there exist a few plugins, like tagbar, that tries to organize information extracted with ctags and present it in a hierarchic view. Note that it won't help with disambiguation nor with auto.

How to access built-in completion sources?

Is it possible to get access for built-in completion sources like keywords in the current buffer or omnicompletion? I am trying to make my own completion manager based on completefunc. I know there is \k character class and I can simply search through the whole buffer but it is such an overhead to deal with on each key presses.
If not, do you know the way to copy all keywords into the list? Keep in mind, I need cursor ordinary atom \%# so the family of match functions is unacceptable.
No, currently there's no such function available in Vim. My CompleteHelper plugin has generic functions to extract arbitrary patterns from buffers; I use it to implement several custom completions. Additionally, I've written emulations of the local keyword and tag completions in this (unpublished) library. Feel free to reuse or derive your own code from it!

Vim repeat blocks of text(code) with parameters

Many times I have come across situations where I need to repeat a code template several times, usually it's boiler plate code. The only thing that would change between different blocks is a few parameter names, which are peppered throughout the block. Is it possible to automate this in Vim without much effort?
snippets are like the built-in :abbreviate on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.
There are three things to evaluate: First, the features of the snippet engine itself, second, the quality and breadth of snippets provided by the author or others; third, how easy it is to add new snippets.

make vim remember my most important command

In vim there are lot of hotkeys, and it is need a lot of time to remember all of them. But there some commands which I don't use often and to use and remember another key sequence is not a need. On the other hand, to remember a hole command and write it even with completion is a good approach. Does somebody know a plugin or a script which explain how to make a list with important commands? It would be good if I can open this list, edit it and select commands.
You might want to know about command-line history: q:, it lets you walk through the list and re-execute with Enter.
Further more, you describe a text file. Vim is /good/ with textfiles :)
Here is an idea to create a mapping that let's you execute a random line from a textfile as a command: (testing)
:nnoremap <C-CR> :exec getline(".")<CR>
(linked to Ctrl-Enter for example)
Some people, me included, use wikis or lightweight blog engines to file away new tricks in a searchable manner as they are encountered. Others may use cross-plateform note taking programs. Others, like voithos, may use pencil and paper. Others don't care that much because they know those advanced tricks will be only a quick google away the next time they need it. Others know that everything and the rest is in :help, including that nifty trick they just saw in a screencast.
But what you really need is probably to edit and grow your .vimrc. Once you figure out a better way to do something add it there and give it a mapping. This file will grow along with your knowledge until you are confident enough to scrap most of it.

Are there any context-sensitive code search tools?

I have been getting very frustrated recently in dealing with a massive bulk of legacy code which I am trying to get familiar with.
Say I try to search for a particular function call, I get loads of results that turn out to be completely irrelevant; some of them are easy to spot, eg a comment saying
// Fixed functionality in foo() so don't need to handle this here any more
But others are much harder to spot manually, because they turn out to be calls from other functions in modules that are only compiled in certain cases, or are part of a much larger block of code that is #if 0'd out in its entirety.
What I'd like would be a search tool that would allow me to search for a term and give me the choice to include or exclude commented out or #if 0'd out code. Then the search results would be displayed alongside a list of #defines that are required in order for that snippet of code to be relevant.
I'm working in C / C++, but other than the specific comment syntax I guess the techniques should be more generally applicable.
Does such a tool exist?
Not entirely what you're after, but I find this quite handy.
GrepWin - A free visual "grep" tool for searching files.
I find it quite helpful because:
Its a separate app (doesn't lock up my editor)
Handles Regular expressions
Its fast
Can specify what folder to search, and what filetypes (handles regex's here too)
Can limit by file size
Can include subdirs (or exclude by regex)
etc.
Almost any decent source browser will let you go to where a function is defined, and/or list all the calls of that function and take you directly to a call site. This will normally be based on a fairly complete parse of the source code so it will ignore comments, code that's excluded by the preprocessor, and so on (in fact, in at least one case, the parser used by the source browser is almost certainly better than the one used in the compiler itself).

Resources