Loading ...
Sorry, an error occurred while loading the content.

Re: filetype indent off

Expand Messages
  • Antoine J. Mechelynck
    ... :filetype indent off will turn off filetype-related indenting for any files _newly_ loaded. To turn it off for a file already loaded, you must then clear
    Message 1 of 5 , Aug 2, 2004
    • 0 Attachment
      - Barry - <mail@...> wrote:
      > I'm new to gVim 6.3, and I was testing out some commands just to see
      > if I could get anything done. I loaded up a pl file, and saw the
      > correct address in the black bar at the bottom of the screen. Then I
      > pressed esc to get in command mode and I entered ":filetype indent
      > off". It showed up correctly at the bottom of the screen, so I
      > pressed return. Then I pressed "i" to get into insert mode, then "{"
      > and hit return, but there was still indentation.
      >
      > What I really want to do is change the auto indentation for pl files
      > to three spaces, but I figured I should learn this more basic thing
      > first. What did I do wrong?
      >
      > Thanks,
      > Barry

      ":filetype indent off" will turn off filetype-related indenting for any
      files _newly_ loaded. To turn it off for a file already loaded, you must
      then clear indenting (":setlocal indentexpr=") or reload the file (":e")
      _after_ you do ":filetype indent off". (No quotes of course.)

      Regards,
      Tony.
    • Mark Woodward
      Hi Barry forgive me if some of this is wrong (I m no guru) ... From: - Barry - To: Sent: Monday, August 02, 2004 7:29 PM
      Message 2 of 5 , Aug 2, 2004
      • 0 Attachment
        Hi Barry
        forgive me if some of this is wrong (I'm no guru)

        ----- Original Message -----
        From: "- Barry -" <mail@...>
        To: <vim@...>
        Sent: Monday, August 02, 2004 7:29 PM
        Subject: filetype indent off


        > I'm new to gVim 6.3, and I was testing out some commands just to see if I
        > could get anything done. I loaded up a pl file, and saw the correct
        address
        > in the black bar at the bottom of the screen. Then I pressed esc to get in
        > command mode

        esc (from insert mode) will take you to 'normal mode'
        ' : ' in normal mode takes you to the command line (command-line mode).
        see :h modes

        > and I entered ":filetype indent off". It showed up correctly at
        > the bottom of the screen, so I pressed return. Then I pressed "i" to get
        > into insert mode, then "{" and hit return, but there was still
        indentation.

        several ways to handle this
        1. command-line mode :set noautoindent
        2. in vimrc set noautoindent
        3. in a ftplugin setlocal noautoindent

        although 1 and 2 look identical, 1 will only persist for current session.
        2 will exist for every session for every file type, but 3 can be used for
        specific file types (this will also be permanent).

        :h ftplugin

        >
        > What I really want to do is change the auto indentation for pl files to
        > three spaces, but I figured I should learn this more basic thing first.
        What
        > did I do wrong?

        create a small vim file 'perl_mystuff.vim' with the following content.
        (note this is a modified version of perl.vim. Also note the name
        perl_something.vim - the perl_ is required. The something part can be
        anything abs, maps etc)
        "-------------------------------------
        if exists("b:did_ftplugin") | finish | endif
        let b:did_ftplugin = 1
        let s:save_cpo=&cpo

        setlocal noautoindent
        setlocal tabstop=8
        setlocal softtabstop=3
        setlocal shiftwidth=3
        setlocal expandtab

        " eg mapping
        inoremap <buffer> <LocalLeader>map This is a map

        " Restore the saved compatibility options.
        let &cpo = s:save_cpo
        "---------------------------------------
        see:
        :h setlocal
        :h autoindent
        :h softabstop
        :h shiftwidth
        :h expandtab
        :h leader

        save this to ~/vimfiles/ftplugin/

        Now the options should only take affect for perl files.

        others will expand on this I hope ;-)
        --
        Mark
      • - Barry -
        ... From: Mark Woodward To: Sent: Monday, August 02, 2004 6:19 AM Subject: Re: filetype indent off ... ... And
        Message 3 of 5 , Aug 6, 2004
        • 0 Attachment
          ----- Original Message -----
          From: "Mark Woodward" <markwoodward@...>
          To: <vim@...>
          Sent: Monday, August 02, 2004 6:19 AM
          Subject: Re: filetype indent off
          ...
          > several ways to handle this
          > 1. command-line mode :set noautoindent
          > 2. in vimrc set noautoindent
          > 3. in a ftplugin setlocal noautoindent
          >
          > although 1 and 2 look identical, 1 will only persist for current session.
          > 2 will exist for every session for every file type, but 3 can be used for
          > specific file types (this will also be permanent).
          ...

          And Tony said: ":filetype indent off" will turn off filetype-related
          indenting for any
          files _newly_ loaded. To turn it off for a file already loaded, you must
          then clear indenting (":setlocal indentexpr=") or reload the file (":e")
          _after_ you do ":filetype indent off". (No quotes of course.)"

          Sounds like the documentation for ":filetype indent off" is misleading. The
          following makes it sound like it turns off auto-indenting with no
          qualifications, resulting in no auto-indenting for the very next block you
          enter, no matter the file type, and eliminating the need to swich it off
          again every time you edit:

          -----

          *30.3* Automatic indenting
          You don't want to switch on the 'cindent' option manually every time you
          edit
          a C file. This is how you make it work automatically:

          :filetype indent on

          Actually, this does a lot more than switching on 'cindent' for C files.
          First
          of all, it enables detecting the type of a file. That's the same as what is
          used for syntax highlighting.

          When the filetype is known, Vim will search for an indent file for this
          type of file. The Vim distribution includes a number of these for various
          programming languages. This indent file will then prepare for automatic
          indenting specifically for this file.

          If you don't like the automatic indenting, you can switch it off again:

          :filetype indent off

          -----

          But I guess I'd need to edit vimrc for such a function, as you said.

          Thanks to all those who responded.

          Barry
        Your message has been successfully submitted and would be delivered to recipients shortly.