Saturday, January 3, 2015

Re: default indentation of perl code

Hi kamaraju!

On Sa, 03 Jan 2015, kamaraju kusumanchi wrote:

> I am finding that the default indentation settings used for perl code
> are not very intuitive.
>
> After spending some time scourging through help files, google etc., I
> arrived at these
>
> autocmd FileType perl set autoindent | set smartindent
> autocmd FileType perl inoremap # X ^H#
>
> My question is why are these options not turned on by default? These
> would make life so much easier for a novice perl programmer using the
> vim editor. Often learning a new language is hard enough... why add
> the additional pain of mastering the editor?
>
> There are probably tons of other vim settings that the majority of
> perl programmers find useful. But I am not knowledgeble enough to
> speak for all of them. In any case turning on the above should be
> least controversial, no?
>
> FWIW the default behavior in emacs is very similar to what I get with
> the above settings. In fact, emacs does something even better. If a
> line does not end in ';' it automatically adds an indent.
>
> For example, if I have
>
> $ emacs parse.pl
> sub read_data()
> {
> a=1
> pressing enter takes me here
>
> sub read_data()
> {
> a=1;
> pressing enter takes me here
>
>
> How can I get similar behavior in vim?

Vim comes with a perl indent file. You might want to enable filetype
specific indenting using :filetype indent on

See http://vimhelp.appspot.com/vim_faq.txt.html#faq-27.1

You might also want to enable filetype plugins, that usually set some
defaults for specific filetypes (e.g. the perl.vim filetype sets the
smartindent setting)
http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.5

Note, filetype specific settings can also be put into their own files:
http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.3


Best,
Christian
--
Ein Mensch, der uns bloß in unsern eignen Talenten übertrifft, erhebt
uns - einer, der in ganz fremden groß ist, demütigt uns.
-- Jean Paul

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: