We’re rewarding the question askers & reputations are being recalculated! Read more.
11

As mentioned in the comments be aware of the consequences this modification has to you work environment (know exactly which eslint rules you use to "fix" things). To answer your question: adding the option to the eslint execution with syntactic is straight forward. Simply add this to your .vimrc: " execute eslint with --fix flag let g:...


8

I recommend filtering your buffer/file through a node module called js-beautify (also available as a python module): :%!js-beautify -f - " whole buffer :'<,'>!js-beautify -f - " selected lines Here is the custom command I have in after/ftplugin/javascript.vim: command! -buffer -range=% Format let b:winview = winsaveview() | \ execute &...


7

The solution given in Jepz's answer didn't completely work for me. eslint was correctly called with the --fix option. However, maybe it's because of internals that have changed, but it seems like checktime was called before the end of eslint --fix, so the file reloading didn't work properly, triggering a file has changed, are you sure you want to write to it?...


5

Per this vim wikia entry you could create a shell execution to new buffer script and then extend it to run your code using node. command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>) function! s:RunShellCommand(cmdline) let isfirst = 1 let words = [] for word in split(a:cmdline) if isfirst let isfirst = 0 " don't ...


5

Close, but you have to use single quotes instead of double quotes, because Vim interprets " as a comment in this context: autocmd FileType javascript setlocal equalprg='js-beautify -f -' Or just escape the spaces: autocmd FileType javascript setlocal equalprg=js-beautify\ -f\ -


4

:g/func/# gives you an actionable outline of the current JavaScript buffer without installing any third party plugin or requiring any external program. Use func\|var to include variable declarations.


4

There is not native way to do this however a few mappings should do the trick. Add the following to ~/.vim/after/ftplugin/javascript.vim: nnoremap <buffer> <tab> :<c-u>call search('\v("<bar>null<bar>\d+<bar>true<bar>false<bar>\[\]<bar>\{\})\ze\n=\s*[]:,}]')<bar>execute "normal! vi". (getline('.')[...


4

Built-in definition search Vim is able to follow "includes" for completion and for navigation. What constitutes an "include" can be defined with the 'include' option. Sadly, Vim's include mechanism is not flexible enough to work with RequireJS's standard way to define multiple dependencies in a same line: define(foo, ["bar", "module/baz"], function(Bar, ...


3

TL;DR Use :h packages You will need the plugin code (github is easiest, though if you just have a copy of the source tree lying around, that works too) A brief history of time managing plugins1 I won't go into extreme detail here unless it is requested. This is mostly a background section, and can be skipped if needed. In the dark ages, you used to need ...


3

Ok, I've figured out a way to do this in my environment. I had to shrink and cut pangloss vim-javascript a little bit. Here's my fork: https://github.com/seavan/vim-javascript-plus You should install it along with vim-jsx in your bundle directory. It will work. I removed some of the latest pangloss updates to make it work. Hopefully I will merge them back ...


3

That feature is built-in, it has nothing to do with that "node" plugin. It's called "include search" and you can read all about it in :help include-search. You have a few ways to jump to an item in the list: :136<CR> will jump to line 136 but it is obviously restricted to the current buffer and you only jump to the line, not the match, :ijump 3 <C-...


3

I think Codi is what you are looking for. It supports JavaScript and some other languages.


3

No plugin required! You can run node with the shell command :! Run the entire file with :!/usr/local/bin/node % Run the current line with :exec '!/usr/local/bin/node' '-e' shellescape(getline('.'))


2

The /usr/share/vim/vim74/syntax/javascript.vim uses this to define what a "string region" is in Javascript: syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc The end option matches either the " character, or the end of the line $, which is why the syntax highlighting stops after the first line. We ...


2

Syntastic allows passing arguments directly to the checkers using the syntastic_<filetype>_<checker>_<option> variable name format. It supports global (g:) and buffer (b:) variants with the buffer having preference over the global one. filetype and checker are obvious so I won't get in detail. option is what interests you. It can be exe, ...


2

What you are looking for has nothing to do with Vim or any editor you are using, you want a tool like grunt.js. Grunt is a task runner that you can configure to do a lot of things automatically, including serving your source files, watching them and reloading the changes. There are a lot of resources online showing you how to do this and this would be out ...


2

The usual way to compile from Vim is to use :make. From :h :make: :mak[e][!] [arguments] 1. All relevant |QuickFixCmdPre| autocommands are executed. 2. If the 'autowrite' option is on, write any changed buffers 3. An errorfile name is made from 'makeef'. If 'makeef' doesn't contain "##", ...


1

What you want is to use a Language Server through the Language Server Protocol (LSP). Read more about it on Wikipedia or on the official website. As the Wikipedia article points out: The Language Server Protocol was originally developed for Microsoft's Visual Studio Code and is now an open standard. So what you get in VS Code is actually being backed ...


1

What if you just enable the filetype plugin? filetype plugin on


1

Let's suppose you have the following lines in your ~/.vimrc source $VIMRUNTIME/macros/matchit.vim filetype plugin on If the offending lines are in a .html file, then: b:match_words = '<:>,' . \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\&...


1

Atom is the only editor I know of that has that capability built-in. You'll need to bring in third party tools. I did some research on a related topic some time back as I was looking for real-time rendering of AsciiDoc markup as I typed it in (I write my work notes in AsciiDoc). The most viable editor-agnostic solution I saw was Live Reload This app watches ...


1

Vim-polyglot vim-polyglot contains what it calls 'language packs', which are sets of syntax, ftplugin, and other files that 'enhance' the experience of working with a particular language. These files work as explained by the help reference, in particular at :help rtp and various topics like syntax, ftplugin, &c. Regexes/syntax Regexes are common to ...


1

As of 2016-12-16, the javascript.vim indenter will break if you set nomagic. The current workaround is to not use set nomagic.


1

I've developed a set of CTAGS regex rules for JavaScript and CoffeeScript. My rules include unit tests so I think they are more reliable than most. Here's my git repo which should be most up to date: https://github.com/winstonwolff/ctags-javascript-coffeescript And here are the rules I use as of writing this post: --languages=-JavaScript --langdef=js -...


1

The documentation states (emphasis added): In JavaScript files, the package will hook into omni completion to handle autocompletion Omni completion doesn't automatically get triggered. It has to be manually invoked using the key sequence <C-x><C-o> in insert mode. Then you can use various keys to navigate the resulting completion menu and ...


1

I didn't find a solution to resolve this issue directly, but I find another Plugin: https://github.com/Chiel92/vim-autoformat. To use this plugin to format javascript, you have to install a global js-beautify node module first: npm install -g js-beautify After the npm module is installed, the plugin will automatically detect it and format js code properly....


Only top voted, non community-wiki answers of a minimum length are eligible