Giter VIP home page Giter VIP logo

detectindent's Introduction

A Vim plugin, for automatically detecting indent settings. This plugin adds a :DetectIndent command, which tries to intelligently set the 'shiftwidth', 'expandtab' and 'tabstop' options based upon the existing settings in use in the active file.

You may wish to consider one of the many forks of this project. Be aware that some of these forks have merged patches that I have been ignoring for good reasons, and that long lists of special cases are not necessarily a good idea...

detectindent's People

Contributors

blueyed avatar brandonaaron avatar ciaranm avatar idbrii avatar jamessan avatar jonasb avatar suokko avatar tom95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detectindent's Issues

Auto run on file open

I want to auto run detectindent when I open a file. It would be nice to have an option that I can pass for it to auto load. Is there a command I can put in my .vimrc to get this working until then?

please add support for Perl

Perl comments are from "#" until line end, like in most contemporary scripting languages.

some_statement(); # this comment lasts until the end of the line

Furthermore, the Perl interpreter skips over documentation written in the POD (Plain Old Documentation) format, so this should be treated like a comment, too. POD looks like this:

some_statement();

=pod

This is documentation.

=cut

some_other_statement();

It is started by any POD command. Such commands always start with "=" and must always appear at the beginning of the line (without any whitespace before them, i.e. column 1). The regexp /^=/ detects POD commands reasonably reliably in Perl code.

A documentation text always ends with the command "=cut", so the end can be found by /^=cut/.

A complete reference of the POD format is available at http://perldoc.perl.org/perlpod.html

Invalid arguments for function <SNR>21_DetectIndent

This error occurs in Vim 7.4.1584:

autocmd BufEnter * :DetectIndent

Error detected while processing BufEnter Auto commands for "*":
E116: Invalid arguments for function <SNR>21_DetectIndent

No error in Vim 7.4.1529.

Ignore multiline comment blocks in HTML and JS

Anything between should be ignored when determining indentation.

/* */ blocks should also be ignored in JavaScript files.

For example, a file starting with the following contents

<!doctype html>
<!--
 * line starts with a space, several lines like it might follow
-->
<html>
<head>
<script type="text/javascript">
function func() {
  if (true) { // line starts with a tab, and all lines following start with tabs

is incorrectly parsed by Detect Indent:

Detected spaces and tabs; has_leading_tabs: 1, has_leading_spaces: 1, shortest_leading_spaces_run: 1, shortest_leading_spaces_idx: 3, longest_leading_spaces_run: 1
Initial buffer settings changed: tabstop changed from 4 to 2, shiftwidth changed from 4 to 1

I expect tabs since the entire file past the comment block on top uses tabs.

Also, is it necessary to check for filetype (HasCStyleComments) when checking for comment lines? Perhaps filetype checks should be removed. I could have a long multiline JavaScript comment with /* and */ in an html file that could throw off Detect Indent, for example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.