stackoverflow syntax highlighting in vim [duplicate] - vim

This question already has answers here:
Enabling markdown highlighting in Vim
(5 answers)
Closed 9 years ago.
Today i woke up with a simple idea.
It would great to have "stackoverflow synthax highlighting in vim".
Do you know a simple way to go SO style ?

Stack Overflow uses Markdown syntax, so this should do it (in Vim versions 7.3+, which ship with it):
:setf markdown
as separate filetype
If you want to do customizations, it's best to define your own custom stackoverflow filetype by creating a file ~/.vim/syntax/stackoverflow.vim with the following contents (and defining corresponding filetype detection rules):
" Quit when a syntax file was already loaded.
if exists('b:current_syntax') | finish | endif
runtime! syntax/markdown.vim syntax/markdown/*.vim
filetype setting from browser
Since Stack Overflow is browser-based, you probably use a browser plugin to do the editing in Vim. I've described such a setup that can automatically set the filetype based on the currently edited URL for Firefox in my blog post Pentadactyl set filetype in external Vim editor based on URL.

Your question is fuzzy; if you mean to mark certain blocks as having a certain syntax (which on Stack Overflow can be done with language: lang-js HTML comments), my SyntaxRange plugin enables you to define a different filetype syntax on regions of a buffer, either manually or automatically based on markers.

Related

Can not get vim to work like i want [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have tried fixing vim to my likings but I alawys encountered a lot of problems due to my lack of knowldege.The most commons ones are:
Powerline font not rendering properly example here
Syntax Highlighting not giving the expected color
Background color not being rendered properly
I am aiming for a result which would look pretty similiar to this when I currently have this.
If the information given is not enough I will give you additional information in the comments. Any help would be greatly appreciated!
You seem to be asking 2 questions:
How do you get fancy font characters for *line plugins?
Where are my syntax highlighting colors?
Fancy font patching
You will need to refer to your status line plugin for how it wants you to patch a font and setup your terminal. vim-powerline for example has instructions on how to do this.
Syntax highlighting colors
You need to make sure you have the following lines in your vimrc file:
filetype plugin indent on
syntax on
This will turn on syntax highlighting and filetype specific plugins (aka ftplugins). As long as you have a color terminal and $TERM is set correctly then the colors should show.
Make sure you also specify a colorscheme via :colorscheme in your vimrc file as well:
colorscheme nord
It should also be noted that nord colorscheme requires you to update your terminal's theme as well in order to work properly.

Regarding the tab size in vim [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have already setup vim size to 4 in ~/.vimrc. It is working when I enter tab, but the original file display tab in size 8. How to make them all in size 4?
Thank you,
:verbose setlocal tabstop? softtabstop? expandtab? shiftwidth?
will show you the current indent settings (and where it got defined). Since these are buffer-local settings, it's not enough to set this once in your ~/.vimrc. Several filetype plugins change these indent settings. (Though typically not 'tabstop', but rather 'softtabstop'.
You could avoid that by turning off filetype plugins altogether (drop :filetype plugin on from your ~/.vimrc), but it's better to selectively override this in the after directory.
Put your :setlocal ... commands into ~/.vim/after/ftplugin/{filetype}.vim. (This requires that you have :filetype plugin on; use of the after directory allows you to override any default filetype settings done by $VIMRUNTIME/ftplugin/{filetype}.vim.) Alternatively, you could define an :autocmd FileType {filetype\} ... directly in your ~/.vimrc, but this tends to become unwieldy once you have many customizations.

vi editor for html indenting [duplicate]

This question already has answers here:
How do I tidy up an HTML file's indentation in VI?
(12 answers)
Closed 8 years ago.
I am doing my development on a redhat linux box having vim of version 7.2. I am doing html, css and javascript development. How can I have the features like indentation feature upon next line, color coding etc.Please suggest me to configure so that my development will be faster and I do not have to copy all the files to my local machine just for indentation.
You need to put these 2 lines in your vimrc for syntax highlighting & filetype specific plugins & indentation rules:
syntax on
filetype plugin indent on
Besides that, you should also add this option in your vimrc to enable vim to autoindent your code based on context when you press a <CR> :
set autoindent
Besides that, there could also be several workflows that you could use, netrw a plugin packaged with vim distributions enables you to open & save files over protocols like ftp, rcp, scp, etc. So you could just open remote files directly from your machine and edit them and save.

How to create your own TComment syntax in vim

Is there a way to make your own comment syntax in TComment because I'm currently studying laravel
and its native templating which is called blade has a syntax for comment which looks like this
{{--Hello i'm a comment--}}
I would like to be able to toggle with this particular comment syntax when i'm editing a file which has an extension of .blade.php
Thanks in advance. If there's a native vim way it would help also. :)
Update:
I'm skimming through the help page of Tcomment and i've stumbled upon this function
tcomment#Comment(beg, end, ...), but i don't know how to implement it since i haven't dealt with vimscript yet. Even a small snippet of how this command is implemented could help
If the other suggestion (using an ftplugin, which is preferable since it provides info for other vim features) doesn't work, you could do (in .vimrc):
call tcomment#DefineType('blade', '{{--%s--}}')
You'd then have to find a way to set the filetype to blade, e.g. (in ~/.vim/filetype.vim)
au BufNewFile,BufRead *.blade.php setf blade
Here is a Solution that works for me:
I create a syntax file for the exotic programming language (my language called HRDT).
If I open a file called .script vim change the file type to HRDT.
My .vimrc contains is line:
autocmd FileType hrdt set commentstring=\\%s
This line automatically change the commentstring from standard *some Text*\ to \some Text .
For commenting I use the very famous NerdCommenter.
It might be that all you need to do is set 'commentstring'. In your case:
setlocal commentstring={{--%s--}}
This would probably go in a filetype plugin/ftplugin.

Folding of text in vim with Markdown syntax plugin

I have a Markdown syntax highlighting plugin installed for Vim (MacVim). It's working well, but it automatically folds down headings, lists, etc.
Does anyone know how to disable the folding of sections completely with a plugin like this? I just want to be able to open Markdown documents without having every section collapsed every time...
Since this question popped up first in my search, I'll duplicate zeuxcg's answer from this question:
set nofoldenable " disable folding

Resources