How can I disable autocomplete in Vim when writing a comment or docstring? I tried au FileType * setl fo-=cro and set fo-=c fo-=o fo-=r but that didn't help. I use Neocomplete.
My OnSyntaxChange plugin may help with this.
First, you need to generate events when entering / leaving comments:
call OnSyntaxChange#Install('Comment', '^Comment$', 0, 'i')
Then, hook commands to enable / disable the auto completion to the events. Fortunately, Neocomplete provides those:
autocmd User SyntaxCommentEnterI silent! NeoCompleteLock
autocmd User SyntaxCommentLeaveI silent! NeoCompleteUnlock
See also this question, which does something similar for the AutoComplPop plugin.
Related
I've recently installed the VimWiki plug-in, and am learning about Vim's plugin architecture in general (and better using directories like after/ftplugin instead of cramming everything into my .vimrc file).
I would like to call a function prior to writing wiki files, like so:
autocmd BufWrite *.wiki call CleanMarkdown()
However, vimwiki sets its own BufWrite autocommand, which updates any tables-of-contents in the wiki file. I could clobber this autocommand with my own function that calls both the CleanMarkdown() plus whatever vimwiki is doing today, but that would be brittle in the face of possible future changes in the vimwiki plugin.
Is there a standard way to add to the list of things to do for a BufWrite autocommand?
Multiplicity of autocmds
There can be many :autocmds for any event; the command is cummulative. The corresponding :autocmd! removes certain sets of commands (depending on the arguments given to it).
If you don't specify a [group], the autocmd will be defined in the global space, and there's a high risk of getting this cleared by some :autocmd!. Therefore, it is recommended to specify a [group] (especially in plugins). With this, you avoid that another (mis-behaving) plugin or customization clobbers your autocmd.
Integrating with vimwiki plugin
As the plugin already defines its own filetype, you don't need to duplicate the filetype detection logic, i.e. the *.wiki pattern. Instead, if you put your :autocmd definition in ~/.vim/after/ftplugin/vimwiki.vim, you can use the <buffer> special pattern to make this autocmd apply only to the current (VimWiki) buffer.
augroup MyVimWikiCleanup
autocmd BufWrite <buffer> call CleanMarkdown()
augroup END
Ordering
The :autocmds are executed in the order in which they were defined. By using the after directory, yours will be executed after the plugin's.
The :Gstatus window has specific mappings for that particular buffer. In my case, I would like to change the cc mapping to not only execute :Gcommit but also go into insert mode afterwards.
It seems like the user robodendron figured out how to do this as shown in https://github.com/tpope/vim-fugitive/issues/647, but I'm don't know what he means when he says "changing the order should be enough." Also, I would ask this on the Git issues page, but it seems like the user NicolasWebDev already tried that and no one got back to him.
I can add mappings by creating a after/ftplugin/gitcommit.vim file, but modifying an existing mapping seems to be more difficult since the mapping is defined after the filetype is set.
Also, I could modify the source code mappings, but we all know that's more of a temporary fix.
I am not sure about trying to alter :Gstatus mappings, but you can start insert mode when entering the commit buffer.
Add the following to your vimrc file:
augroup turbo_commit
autocmd!
autocmd BufEnter COMMIT_EDITMSG startinsert
augroup END
For more help see:
:h :autocmd
:h :augroup
:h BufEnter
:h startinsert
I am using VIM as the editor for SystemVerilog. I have three questions.
In some posts I saw there is a auto-complete function for VIM.
1.How can I enable auto-complete function for my Systemverilog files in VIM??
2.How can I auto-indent a selected portion in VIM?
3.How can I enable folding in VIM?
I am using plugin created by Nachum Kanovsky in VIM for Systemverilog
Just in case, make sure you have these two lines in your ~/.vimrc:
filetype plugin indent on
syntax on
Assuming the linked plugin is installed and working correctly this will get you proper indenting and syntax highlighting for every supported language.
I can't find a Systemverilog-specific omnicompletion script on vim.org but you can still use basic syntax-based completion. Add these lines to your ~/.vimrc:
augroup Systemverilog
autocmd!
autocmd FileType systemverilog setlocal omnifunc=syntaxcomplete#Complete
augroup END
The completion menu is activated by pressing Ctrl+XCtrl+O in succession.
See :help ins-completion.
"Auto indenting" should happen automatically. If you want "formatting", select a few lines and press =.
Modify the autocommand above:
augroup Systemverilog
autocmd!
autocmd FileType systemverilog setlocal omnifunc=syntaxcomplete#Complete foldmethod=indent
augroup END
Please try out my verilog_systemverilog.vim fork where I try to implement this functionality.
Note: this functionality still has limitations, so please open issues requesting features and/or reporting bugs.
As you know, there are (sadly) no VisualLeave or VisualEnter autocmds in vim. Is there a way to emulate it?
(Sidenote: Having such events would add even more power to vim)
So far, the best solution is here: Run command when vim enters visual mode
It is a workaround to not having the Visual* autocmd events.
The one IDE feature that I always missed and invariably plug into vim is tab completion.
I'm a big fan of SuperTab, but one thing I can't stand is the fact that it treats the parts of CSS class names and IDs with dashes as individual words.
I've found a couple of possible solutions for camelCase and underscore_completion but I can't seem to find anything that supports plain-old-dashes.
This is not a CSS-specific problem: Vim uses the value of iskeyword to perform completion.
Type :set iskeyword? to see what characters are considered to be part of keywords. The default on a Mac is supposed to be #,48-57,_,192-255.
You can add the dash to the list with this command:
:set iskeyword+=-
Add this line to your ~/.vimrc to make this setting stick:
set iskeyword+=-
This seems to work for me:
autocmd FileType css,scss set iskeyword=#,48-57,_,-,?,!,192-255
Taken from here: VIM: How to autocomplete in a CSS file with tag ids and class names declared in HTML file
For future readers: if you want the benefits of dashes for edit/movement commands, but want full property autocompletion, try adding this to your .vimrc:
augroup css_dash_autocompletion
autocmd FileType scss,css autocmd! css_dash_autocompletion InsertEnter <buffer> set isk+=-
autocmd FileType scss,css autocmd css_dash_autocompletion InsertLeave <buffer> set isk-=-
augroup END
The first ! prevents duplicate event firing. Thanks to ZyX for the structure. If you re-source your .vimrc, you will need to :e any (S)CSS files you have open to pick up the change.