vi editor for html indenting [duplicate] - vim

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.

Related

How to add Syntax Highlighting in Vim for .ini files

I recently started using Vi Improved and being a Rainmeter Skin Specialist, when editing my .ini files I can't find a way to add syntax highlight for such files. I searched for a lot of time on stack and git and turned up to nothing. Requesting help at the latest.
TLDR; Need .ini file syntax highlighting for Vim
Vim already has syntax highlighting for *.ini files.
If your Vim is reasonably recent, say 8.0 and up, and you didn't set anything up with regards to Vim (no $HOME\_vimrc, nothing), then your *.ini files should be highlighted without any human intervention at all.
The screenshot below was taken in a test VM with a basic Vim without any setup:
If you have already customised Vim, with a $HOME\_vimrc file and/or with a $HOME\vimfiles directory, then you are in full control, which means that the automatic stuff described above is no longer done for you anymore. And being in full control of Vim pretty much requires that you learn it properly and configure it as you go.
Having EITHER of the following lines in your $HOME\_vimrc or $HOME\vimfiles\vimrc is going to give you automatic syntax highlighting for any recognised filetype:
syntax enable
syntax on

stackoverflow syntax highlighting in vim [duplicate]

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.

How do you set up formatting in vim?

Earlier, when I used open .py files in vim on ubuntu, they would be well formatted, with separate colours for separate segments of the program. Now, when I am using VIM on ubuntu, all the text in the .py file appears black. How can I correct this?
Formating in Vim means text formatting; e.g. indenting lists and breaking long lines. You're concerned about syntax highlighting, which is purely about the visual appearance of code.
First, it needs to be turned on.
:syntax on
does that.
Second, you probably want Vim to automatically detect the used language (e.g. Python) and choose the correct syntax plugin for you.
:filetype on
does that, though you usually enable more via :filetype plugin indent on.
To make these settings persistent, put them into your ~/.vimrc configuration.
Check man vim. In a nutshell, find a copy of a vimrc file, one might be under /usr/share/vim/ subtree. It may be named vimrc_example.vim. Copy to your home directory and rename it as .vimrc.

Any default settings possible for VIM editor?

I use ":set ai sw=4" and ":set number" (and some other cmd) commands each time when I open any file in VIM.
For every new instance of VIM I have to enter set of commands. Is there any way where I can put these commands and VIM will execute it every time while opening any file like default settings.
Just paste those lines on the file ~/.vimrc and they'll be executed everytime VIM is openned. If it does not exist, create one.
Two recommendations:
Use a plugin that will auto-load .vimrc when you save it. Being confortable with editting .vimrc is very important. Building it up with your preferences and key-mappings as you learn VIM is one of the reasons it is so powerful.
Google now for some ready .vimrc setups as they override some not-so-optimal VIM configurations. For example, you probably won't want that annoying bell beep, among many other things.
You need to create a .vimrc file.
You should create it in your home directory.

How can I configure VIM so that files with extension .less are edited with zen-coding?

How can I configure VIM so that files with extension .less are edited with zen-coding?
I can use within the zencoding notepad + + on windows normally. But now I want to use the same way inside vim.
ZenCoding is probably activated on a per-filetype basis, if that's the case, just type :set filetype=css.
If you want this setting to stick, add this line to your .vimrc:
autocmd BufRead,BufNewFile *.less set filetype=css
If you want to retain the normal features that go with .less files (if any) you can do :set ft=less.css but some plugins don't like that.
I first tried to write a comment, but found then something that could be an answer.
So I think the question is: How can I configure VIM so that files with extension .less are edited with zen-coding?
At the official site for zen-coding, there are lists of editors that support zen-coding:
Official
third-party
Unofficial
There for VIM, the following sites are mentioned:
Sparkup
Zen Coding for VIM
I have read into both, and both seem to expand shortcuts to HTML code, not to less-code. But perhaps I have misunderstood the question.
I didn't know you could use Zencoding for css. I use it in Vim for html.It s great!I started using Less and I was wondering an hour ago ,If something like this existed. I guess it's something to work on.

Resources