As of May 31, 2023, we have updated our Code of Conduct.
13 votes

How to auto fix common linting errors reported via syntastic?

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 ...
JepZ's user avatar
  • 231
8 votes

Minimal to effort to have a JS beautifier on vim

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 - " ...
romainl's user avatar
  • 36.9k
7 votes

How to auto fix common linting errors reported via syntastic?

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 ...
Jerska's user avatar
  • 171
6 votes

How can I run javascript directly and show the output?

I think Codi is what you are looking for. It supports JavaScript and some other languages.
Tae's user avatar
  • 1,980
5 votes

How can I run javascript directly and show the output?

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('.'))
Nate's user avatar
  • 151
5 votes
Accepted

How can I run javascript directly and show the output?

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(<...
jecxjo's user avatar
  • 2,590
4 votes
Accepted

How to pass a parameter to JSHint with Syntastic

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 ...
tokoyami's user avatar
  • 915
4 votes
Accepted

Is there a way to tab through fields and values in a JSON file in Vim?

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('...
Peter Rincker's user avatar
4 votes
Accepted

Is it possible to get tag navigation that works with RequireJS?

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 ...
romainl's user avatar
  • 36.9k
4 votes

VIM How to enable .ts .tsx .js (for front-end) code highlight?

The best thing to do is enable filetype detection: filetype on Vim defaults to setting .tsx files as typescriptreact (8.1.2100 for me at least). To enable filetype-plugins and indent scripts (...
D. Ben Knoble's user avatar
  • 23.9k
4 votes

VIM How to enable .ts .tsx .js (for front-end) code highlight?

I tried to use augroup SyntaxSettings autocmd! autocmd BufNewFile,BufRead *.tsx set filetype=typescript augroup END and it works.
Oleg Ovcharenko's user avatar
4 votes
Accepted

How to manually install pangloss JavaScript plugin?

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 ...
D. Ben Knoble's user avatar
  • 23.9k
3 votes

Are there color variables for various programming languages?

A "color scheme" is not language-specific. Every file will use the same color scheme. Here's an old question with some good answers on creating your own color scheme, though, if that's ...
MDeBusk's user avatar
  • 363
3 votes
Accepted

How to jump to the location which [I points to?

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 ...
romainl's user avatar
  • 36.9k
3 votes

Vim auto indentation

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 ...
Samvel Avanesov's user avatar
2 votes

How do I get matchit to work with '/>' (self-closed tags)?

Instead of using the above config, you can easily use a< from visual mode to select around closing tag, i< to select inner a closing tag.
lehanh's user avatar
  • 121
2 votes
Accepted

Is there a workflow to preview javascript/html/css projects inside the browser?

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, ...
statox's user avatar
  • 48.5k
2 votes

I want to save my typescript file, and immediately run tsc myfile.ts from inside vim. What is the best way to accomplish this?

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' ...
muru's user avatar
  • 24.5k
1 vote
Accepted

How to set prettier indents?

For anyone who is facing a similar issue, when you use the prettier extension via coc-prettier, you need to put the configuration options inside the coc-settings.json file. To solve my issue of ...
Vinn's user avatar
  • 607
1 vote
Accepted

vim-test :TestSuite return message Not a test file

So I found the issue and a workaround. The issue is on Windows the path separator is \ and not / as is written in the code. There is also a Windows in jasmine.vim when using the jasmine executable ...
Geoff's user avatar
  • 111
1 vote

'filetype plugin indent on' breaks indention

What if you just enable the filetype plugin? filetype plugin on
padawin's user avatar
  • 1,313
1 vote
Accepted

Sophisticated autocompletion in Vim in a VScode manner

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 ...
filbranden's user avatar
  • 27.5k
1 vote

Is there a workflow to preview javascript/html/css projects inside the browser?

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 ...
B Layer's user avatar
  • 19.1k
1 vote
Accepted

Enabling Syntax in Vim Creates Lag

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 ...
D. Ben Knoble's user avatar
  • 23.9k
1 vote

How can I change Javascript syntax to higlight objects?

Try plugin https://github.com/jaxbot/semantic-highlight.vim (see also the article). To install (with Plug plugin manager), set in .vimrc Plug 'jaxbot/semantic-highlight.vim' Default colors fight ...
Giorgio Robino's user avatar
1 vote
Accepted

Configure JavaScript indentation to indent keys object literals

As of 2016-12-16, the javascript.vim indenter will break if you set nomagic. The current workaround is to not use set nomagic.
Greg Nisbet's user avatar
  • 1,755
1 vote
Accepted

How do I get matchit to work with '/>' (self-closed tags)?

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 = '<:>,' ....
Jair López's user avatar
  • 1,794
1 vote

How to view javascript tags in vim using tagbar + jsctags + tern_for_vim + ctags_exuberant?

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: ...
Winston's user avatar
  • 111

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