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.
Related
I would like to set up VIM for Cobol development and wanted to have the lines form column 7 to 11 marked so as to indicate the code areas. However, when I added this line of code in my vimrc file it colorized the NERDTree too.
set colorcolumn=7,11,73,80
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
How can I make the NERDTree columns not colorized and keep colorization only on the working file?
With the following line in your vimrc:
set colorcolumn=7,11,73,80
you define a global value for a window-local option which is reused for every new window. It is set for the 1st window, which passes it on to the 2nd window, etc.
Since that specific value for that specific option only is to be applied to Cobol buffers, you are supposed to use Vim's built-in filetype plugin support:
Make sure you have either of those lines in your vimrc:
filetype plugin on
filetype plugin indent on
filetype indent plugin on
See :help :filetype.
Create after/ftplugin/cobol.vim under your Vim runtime. On a typical Unix system, it should look like this:
$HOME/.vim/after/ftplugin/cobol.vim
And add the line below:
setlocal colorcolumn=7,11,73,80
We use :help :setlocal to make sure that the option won't be passed on to other windows.
I want to disable syntax highlighting for a particular programming language. I'm currently using this
au FileType foo syntax off
however this has the problem that it disables syntax highlighting for any new buffers that I open in the same window, even when they have different filetypes. Is it possible to disable syntax highlighting only for this filetype? (e.g. any other buffers in the same window that has different filetype should have syntax highlighting enabled)
One of the things that could solve this problem is to create a syntax/foo.vim file that doesn't highlight anything, but I'm not sure how to implement this when foo is one of the languages that vim highlights by default.
au FileType foo setlocal syntax=OFF
If you want to isolate the config a bit, create a file called ~/.vim/after/ftplugin/foo.vim and put this in it:
setlocal syntax=OFF
I'm not sure if this is the right place to ask about this, but I figured it couldn't hurt to ask here. I am using a plugin called auto-close so that I don't have to close my own parentheses. It has a very nice feature that does the following:
This is a great feature, but I don't like how far it indents for me.
I have the following line in my .vimrc:
" for filetype "js", tab = insert 4 spaces, backspace will delete all 4
autocmd Filetype javascript setlocal expandtab softtabstop=4
In editing a javascript file, it automatically did an 8-space indentation instead of a 4-space indenation, as I've specified in my .vimrc. Can anybody help me figure out how I can make it automatically indent 4-space tabs instead of 8-space tabs? I can't find it in the documentation either. Thanks!
If you get shiftwidth=8, softtabstop=0, tabstop=8, that means that your autocmd FileType didn't take effect. You'd have to troubleshoot that.
I would recommend putting any settings, mappings, and filetype-specific autocmds into ~/.vim/ftplugin/{filetype}_whatever.vim (or {filetype}/whatever.vim; cp. :help ftplugin-name) instead of defining lots of :autocmd FileType {filetype}; it's cleaner and scales better; requires that you have :filetype plugin on, though. Settings that override stuff in default filetype plugins should go into ~/.vim/after/ftplugin/{filetype}.vim instead. The change of indent settings would fit the latter, after directory location.
I'm happily loading either Notes and Txtfmt plugins in neovim, command line version, on Mac Os Sierra.
Both greatly working on their own, but no chance to have 'em loading together in a file of filetype notes.txtfmt as per Vim documentation about dot-separated filetypes.
First attempt I made was following Notes documentation to be able to work together with Txtfmt and creating the file
$/.vim/after/ftplugin/notes.vim
with the content:
" Enable Txtfmt formatting inside notes.
setlocal filetype=notes.txtfmt
As stated in this discussion this approach does not work, creating an infinite loop.
Next, as suggested by bpstahlman in the mentioned post, I added to my .vimrc the following autocommand:
augroup TxtfmtInNotes
au!
au FileType * if expand("<amatch>") == "notes" | setlocalft=notes.txtfmt|endif
augroup END
Now, it seemed that could be working, in that it declares a 'notes.txtfmt' filetype in Vim status bar, immediately after opening a new :Note buffer.
The bad news: txtfmt plugin does not load, no mapped command is working.
The funny: doing again :setlocal ft=notes.txtfmt
(which is supposed to have already been done by the suggested autocommand) everything gets properly loaded.
In other words it looks like in my case the autocommand works in changing filetype but not in loading the txtfmt plugin, which is loaded only repeating the filetype command.
Any suggestion on this?
Thanks
If the Notes plugin had a filetype detection (apparently it hasn't, and the filetype is only set by the commands the plugin provides), I would overwrite that to
:au BufNewFile,BufRead *.note setf notes.txtfmt
In your case, instead of using a compound filetype, I would simply emulate its effects in ~/.vim/after/ftplugin/notes.vim:
runtime! ftplugin/txtfmt.vim ftplugin/txtfmt_*.vim ftplugin/txtfmt/*.vim
I haven't tested it, but it's more straightforward and therefore hopefully more robust than your current solution of hooking into the FileType event.
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.