Vim SuperTab: How to specify suggestions source - vim

I have been playing around with the Vim-plugin "SuperTab" for a while, and it has become nearly unusable to me due to the enormous delay following the press of the [Tab] key. This is due to SuperTab using tag files as a source for result suggestions.
This is problematic to me since the tag file for our codebase at work is quite big (37mb~), so depending on the situation, hitting [Tab] sometimes invokes a query that may take 15+ seconds to complete. Not quite a time-saver.
Is there any way to tell SuperTab to ignore my tags variable, because I would very much like to keep using it for other plugins like taglist.vim, or optionally, an alternative to SuperTab?

Supertab uses the default completion; its sources can be configured via the 'complete' option. A
:set complete-=t
should remove the tag completion; other plugins won't be affected, but the default insert mode completion (<C-n> / <C-p>) is. Alternatively, you could reconfigure Supertab to use another completion, e.g. the buffer-local one (<C-x><C-n>).

Related

Vim8 cannot delete letters

I installed a vim 8.1 on the cluster I am using in my home folder. I also installed a number of plugins including YouCompleteMe. I then made an alias so that I can open the vim easier.
However, I found that my vim cannot delete letters very well. When I am writing I can delete what I just typed. But if I move the cursor to other places, then it cannot delete letters at all, unless I type in something at first.
I am using a Scientific Linux system developed by the Fermi Lab.
How can I solve this problem?
Thanks
This sounds like the default configuration of the :help 'backspace' option. If this doesn't contain start, you cannot remove characters over the start of insertion by pressing Backspace, only what got inserted before. Removal of characters via the x or d commands (:help deleting) should always work - anywhere. Else, you have a serious misconfiguration should inspect your ~/.vimrc and re-add plugins one by one.
If you're new to Vim (and using backspace for deletion in insert mode is a typical approach of people used to other, modeless editors), you should spend 30 minutes on the vimtutor that comes with it (see :help vimtutor). Then, there are several good resources, cheatsheets, and vi / Vim tutorials out there on the net. http://vimcasts.org/ has several short entertaining episodes that go beyond the basics.
Your problem could be fixed by putting
set backspace=indent,eol,start
into your ~/.vimrc. Also have a look at :help defaults.vim; by including that instead, you'll get other goodies and recommended settings as well! (The reason for the odd defaults is backwards compatibility.)

vim: disable plugin by default (diffchar)

Recently (vimdiff: force line-by-line comparison (ignore supposedly missing/additional lines) ), I've found the quite useful vim plugin diffchar, which improves vimdiff by showing multiple diffs on the same line separated, instead of highlighting the whole area from the first to the last diff.
The problem is that I frequently encounter files where diffchar doesn't work properly, namely spills out a whole lot of errors when vimdiff is opened, plus I think it slows down vimdiff substantially for large files (which I'm dealing with far too often).
Is there a way to disable this (or any) plugin by default?
The plugin already has the functionality to turn it off (toggle it), mapped to F7. What I'd like is that it's turned off by default, but that I'm still able to turn it on (using F7) when I specifically need it. (I'm also fine with tweaking the source file of the plugin accordingly, BTW.) What I've already tried is simply adding the command F7 is mapped to (ToggleDiffCharAllLines) to .vimrc, but this doesn't work.
Just put this into your ~/.vimrc:
let g:DiffExpr = 0
You then have to explicitly enable the plugin via one of its mappings or commands.

How do you change the default ESC to exit insert mode in LightTable's Vim?

I'm posting this question largely to provide the answer I've arrived at (because I found nothing elsewhere online and see no questions asking how to do this), to hopefully save future LightTable vim users a bit of time. But I'd also like to hear about any other solutions people have found to this problem, or vim LightTable problems in general.
I've fallen in love with LightTable, but at least minimal vim support is a must before I even consider an IDE. LightTable has that. Currently, though, you're largely stuck with the default vim options and little ability to alter configuration. I would be very interested in hearing about what the future plans are in this area (you out there Chris?). Exposing a .vimrc in a local config directory, even if highly limited in functionality, would be simply awesome, but I realize its very early yet in development and largely depends on what CodeMirror can provide.
One thing I can't tolerate is having to send my pinky way up and to the left to hit the ESC key to exit insert mode. That is way too slow and requires your left fingers to leave the home row, which is never good. The way I normally handle this in vim is to map ii to exit insert mode in .vimrc. Another alternative that is there by default is to hit CTRL-[. That's better, but to me that's entering emacs chording territory and for some reason my right pinky finger almost always flubs hitting either of the bracket keys.
This is a bit of hack, but it's a tolerable work-around until better vim support comes along in LightTable/CodeMirror. I've only tested it on the latest LightTable (0.4.9), so I'm not sure how applicable it is to earlier versions (which you probably shouldn't be on anyways), or, for that matter, later versions that will come along.
There is a command option called "Vim: toggle vim mode". This turns vim on and off in an editor (or instarepl). You can bind this command to a hot-key combination via the "Settings: Change key bindings/shortcuts" command. This will open up a new tab where you can enter new key bindings on the left. The current key bindings are shown on the right.
I use SHIFT-i, within a context of :editor.keys.normal. (This means I can't use capital "I" directly in the text, but in actual practice with program editing - especially clojure - this almost never causes a problem, and if it does you can just use lower-case i and then back up and do a replace char.) This effectively makes "II" (SHIFT-i SHIFT-i) the means of exiting insert mode. The first SHIFT-i exits vim and puts you in the normal, WYSIWYG editor. The next SHIFT-i puts you back in vim, but in command mode. Voila! You've went from vim insert mode to vim command mode.
Hope this helps other LightTable vim users.
Update: I think the latest LightTable release supports this. Someone please comment if adding the following to their user.behaviors file works (user behaviors is accessible via the command pane (ctrl-space)):
[:editor :lt.plugins.vim/set-options {"enableInsertModeEscKeys" true,
"insertModeEscKeys" "jk",
"insertModeEscKeysTimeout" 200}]
Old answer:
The latest LT plugin source supports this, but has not been released yet.
To easily install it do the following:
Open your LT plugins folder, e.g. on OSX ~/Library/Application Support/LightTable/plugins/Vim/
(Optional) Save a backup of the Vim (plugin) folder somewhere else
Delete the Vim folder
Download https://github.com/LightTable/Vim/archive/master.zip
Unzip it, rename the unzipped folder to just Vim, and move/copy it to your LT Plugins folder (i.e. it is replacing the official Vim plugin that you just deleted)
Add the following options in the :editor section of your user.behaviors file:
(:lt.plugins.vim/set-options {"enableInsertModeEscKeys" true,
"insertModeEscKeys" "jk"
"insertModeEscKeysTimeout" 200})
Restart LT and you should be able to use jk (or whatever keys you set in insertModeEscKeys) to exit insert mode
CodeMirror's API is designed in such a way that it's not very complicated to add key bindings but adding support for a configuration file and extending the default key bindings to cover a larger part of Vim's feature set doesn't exactly sound like a trivial task to me. And, considering the fact that LT doesn't even have search/replace, probably something that is near the bottom of their TODO list.
That, and CodeMirror is a third party "library" on which the LT team probably doesn't have much leverage.

How do I combine two features of vim wiki plugins?

Sorry in advance for the newbie question. I've been trying to use vim for keeping a personal wiki, but I can't quite seem to decide on a good plugin. Vimwiki is great, and I really like the way it does checkboxes and uses the enter key to follow links. Notes.vim is simpler but I like it a lot better: it dynamically makes names of notes into links like Tomboy Notes, makes pretty bullet points, and has a search function built in. I can't get vimwiki to use files with no extension, but notes.vim does that automatically.
What I want to know is: is there an easy way (calling a vimscript file or something?) to combine some features of both of these plugins? I've tried doing some cutting-and-pasting but so far nothing has been working.
I doubt whether tbere is any simple automated way to do it. Both Vimwiki and notes.vim are "filetype" plugins. Generally in Vim any file (or buffer) can be set to just a single filetype.
It would depend on how the ftplugins were written, but it may be possible to apply them both to same buffer by making sure that the buffer is set to both filetypes, sequentially. That is, the buffer can be set to one filetype at a time, but setting it to both one after the other may do part of what you need.
For example, opening a notes.vim file will automatically set the buffer to a notes.vim filetype. Once open you could issue the command :setlocal filetype=vimwiki to change it to a vimwiki buffer. If vimwiki filetype initialization doesn't wipe out crucial notes.vim settings or have conflicting operation then you may then be able to access some functionality from both ftplugins. Not likely to get you very far, but maybe worth a try. Better would be to combine sections of their code into a single ftplugin.

Vim: Making Auto-Completion Smarter

I use ctags, taglist, etc., to have auto completion in Vim. However, it is very limited compared to Visual Studio intellisense or Eclipse auto-completion. I am wondering whether it is possible to tune Vim to:
Show auto-completion whenever . or -> are typed. But only after some text that might be a variable (e.g. avoid showing auto completion after a number).
Show function parameters when ( is typed.
Stop removing the auto completion list when some delete all characters after . or ->: When I enter a variable name, then press . or -> to search for a certain member, I frequently have to delete all the characters I type after the . or ->, but this makes Vim hide the auto completion list. I would like to keep it visible unless I press Esc.
Showing related auto completion: When I type a variable and press ^X ^O, it usually shows me all the tags in the ctags file. I would like to have it showing only the tags related to the variable.
Thanks for the help.
EDIT: Some people are voting for this question, but no body seems to know the answer. So just wanted to mention that you don't have to provide a complete answer; partial answers to any of the mentioned points would be good also.
AutoComplPop is what you need.
For (1) when working with C++ or C clang complete is a really nice option
To make vim trigger a certain behavior when a key is pressed you need to map the key to a function.
For instance to map the key . to call some type of completion when in INSERT mode you would need to do:
:inoremap <expr> <buffer> . MyFunction()
and then the function would need to evaluate the context where it was called and present an appropriate answer to the user.
Edit: This is the basis of how clang complete mentioned by #honk works.
I'm not sure if you can customize the behavior of omnifunc to meet your needs but on my experience, I never went too far. As #Mikhail said, you would need to keep track of things which in practice means interpreting or even running the code to some extent.
I use vim every day, and I'm not aware of any existing script that may do this. This action would require understanding of classes and keeping track of variables. someObject-> means that VIM would know what class the variable someObject is, and then be able to search methods/variables within that class.
Writing scripts for vim is relatively easy, though like you've commented - no one has answered this yet. Up vote from me.
I would love to have that same functionality that you are looking for and just came across a promising plugin:
https://github.com/Shougo/neocomplcache looks like it could be the new autocomplpop, and seems to work quite well during my initial trials... now to configure the omni completion to work with scala~
I've recently discovered YouCompleteMe, it behaves similarly to the Visual Studio autocomplete tool. A demonstration can be seen here:
https://www.youtube.com/watch?v=YuMyHAHF0xs
In any case, I recommend YouCompleteMe (YCM). It provides (fuzzy) matching of identifiers of your current file, as well as path-completion, integration with external completion engines,...
ad 1)
If you like the semantic completion of eclipse, use eclim to integrate vim with eclipse. (alernatively use another semantic engine for YCM)
ad 2)
These 2 play nicely together btw.,: YCM can even provide the function definition (= parameter list) of the recently completed function!
ad 3)
that's what YCM does anyways
ad 4)
not quite sure, what you mean by that one. never used ctags!
P.S.: I strongly recommend using UltiSnips and Tagbar (and if you like UndoTree) additionally, what makes vim a perfect IDE for me.

Resources