How to disable and replace Vim's standard formatting of Pascal

已查看 11 次
跳至第一个未读帖子

Steve Litt

未读,
2023年6月13日 21:18:132023/6/13
收件人 vim...@googlegroups.com
Vim handles formatting for most computer languages wonderfully. But not
Pascal. My writing of Pascal programs is slowed horribly by Vim's
bizarre formatting.

Using grep, I found there are no files whose names contain the string
"pascal" in any case in the ~/.vim directory (I'm using Void Linux).

All I really need is to disable Vim's "helpful" indentation, and then:

Set ai
Set expandtab
Set tabstop 3
Set shiftwidth 3

Thanks,

SteveT

Steve Litt
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm

Tim Chase

未读,
2023年6月13日 21:37:202023/6/13
收件人 vim...@googlegroups.com
On 2023-06-13 21:18, Steve Litt wrote:
> Using grep, I found there are no files whose names contain the string
> "pascal" in any case in the ~/.vim directory (I'm using Void Linux).

I suspect your frustration is being caused by something in
$VIMRUNTIME/indent/pascal.vim

As such, you should be able to do something like (optionally putting
your settings in there, too)

$ mkdir -p ~/.vim/indent
$ cat >> ~/.vim/indent/pascal.vim <EOF
let b:did_indent = 1
set ai
set expandtab
set tabstop 3
set shiftwidth 3
EOF

or possibly adding something like

autocmd FileType pascal let b:did_indent=1

to your ~/.vimrc might at least prevent the stock indentation
settings.

-tim





Steve Litt

未读,
2023年6月14日 03:09:422023/6/14
收件人 vim...@googlegroups.com
Tim Chase said on Tue, 13 Jun 2023 20:37:10 -0500

>On 2023-06-13 21:18, Steve Litt wrote:
>> Using grep, I found there are no files whose names contain the string
>> "pascal" in any case in the ~/.vim directory (I'm using Void Linux).
>>
>
>I suspect your frustration is being caused by something in
>$VIMRUNTIME/indent/pascal.vim

Correct: ~/.vim/indent didn't exist, so I followed your instructions...

>
>As such, you should be able to do something like (optionally putting
>your settings in there, too)
>
> $ mkdir -p ~/.vim/indent
> $ cat >> ~/.vim/indent/pascal.vim <EOF
> let b:did_indent = 1
> set ai
> set expandtab
> set tabstop 3
> set shiftwidth 3
> EOF

The preceding worked. Now I can tab and Ctrl+d or Ctrl+t for
*space-only* indentation of three spaces in insert mode. Naturally,
I can use << and >> in command mode. It's beautiful. Vim doesn't try to
guess what I want in indentation: It lets me do it manually, which is
just what I want.

>
>or possibly adding something like
>
> autocmd FileType pascal let b:did_indent=1
>
>to your ~/.vimrc might at least prevent the stock indentation
>settings.

The preceding didn't work, but that's OK, your main solution worked, so
thank you!

Tony Mechelynck

未读,
2023年6月14日 04:04:032023/6/14
收件人 vim...@googlegroups.com
On Wed, Jun 14, 2023 at 3:18 AM Steve Litt <sl...@troubleshooters.com> wrote:
>
> Vim handles formatting for most computer languages wonderfully. But not
> Pascal. My writing of Pascal programs is slowed horribly by Vim's
> bizarre formatting.
>
> Using grep, I found there are no files whose names contain the string
> "pascal" in any case in the ~/.vim directory (I'm using Void Linux).
>
> All I really need is to disable Vim's "helpful" indentation, and then:
>
> Set ai
> Set expandtab
> Set tabstop 3
> Set shiftwidth 3
>
> Thanks,
>
> SteveT

I think Tim's answer is right. Now for a bit of explanation, as found
in the help for 'runtimepath' (in my gvim and with my 'guifont' this
uses about two screenfuls of help text):

• $HOME/.vim/ or $HOME/vimfiles (depending on OS), and their
subdirectories other than after/, are meant for single-user private
scripts to be run first;
• $VIM/vimfiles/ and its subdirectories other than after/ are meant
for system-wide scripts to be run before those distributed with Vim.
These scripts are normally put there by a system administrator;
• $VIMRUNTIME/ and its subdirectories contain scripts coming from the
Vim distribution. Users and even system administrators should keep
hands off them because any user's changes there will disappear the
next time the Vim runtime files are updated;
• $VIM/vimfiles/after/ and its subdirectories are meant for
system-wide scripts placed there by a system administrator, to be run
after those in or under $VIMRUNTIME;
• $HOME/.vim/after/ or $HOME/vimfiles/after/ (depending on OS), and
their subdirectories, are for single-user private scripts to be run
last.

So if you found nothing called "pascal" (or "pascal.vim") in or under
~/.vim/ it just means that you hadn't put anything such there
yourself. Scripts responsible for any "weird behaviour" on the part of
Vim as distributed by Bram have to be looked for in the $VIMRUNTIME
directory tree. Similarly, weird behaviour in a Vim distributed via
your Unix/Linux/Mac distribution and not found in other distributions
or in "vanilla" Vim as compiled from Bram's pristine sources, might be
due to scripts placed under $VIM by whatever software distribution
brought Vim to you, or to a "system vimrc" (often, but not
necessarily, at /etc/vimrc) of the same origin.

Best regards,
Tony.

Bram Moolenaar

未读,
2023年6月14日 06:24:582023/6/14
收件人 vim...@googlegroups.com、Steve Litt

> Tim Chase said on Tue, 13 Jun 2023 20:37:10 -0500
>
> >On 2023-06-13 21:18, Steve Litt wrote:
> >> Using grep, I found there are no files whose names contain the string
> >> "pascal" in any case in the ~/.vim directory (I'm using Void Linux).
> >>
> >
> >I suspect your frustration is being caused by something in
> >$VIMRUNTIME/indent/pascal.vim
>
> Correct: ~/.vim/indent didn't exist, so I followed your instructions...
>
> >
> >As such, you should be able to do something like (optionally putting
> >your settings in there, too)
> >
> > $ mkdir -p ~/.vim/indent
> > $ cat >> ~/.vim/indent/pascal.vim <EOF
> > let b:did_indent = 1
> > set ai
> > set expandtab
> > set tabstop 3
> > set shiftwidth 3
> > EOF
>
> The preceding worked. Now I can tab and Ctrl+d or Ctrl+t for
> *space-only* indentation of three spaces in insert mode. Naturally,
> I can use << and >> in command mode. It's beautiful. Vim doesn't try to
> guess what I want in indentation: It lets me do it manually, which is
> just what I want.

Suggestion: Use "setlocal" instead of "set" to avoid affecting other
files. You only want to apply these options locally.

--
hundred-and-one symptoms of being an internet addict:
166. You have been on your computer soo long that you didn't realize
you had grandchildren.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Steve Litt

未读,
2023年6月14日 16:28:332023/6/14
收件人 vim...@googlegroups.com
Bram Moolenaar said on Wed, 14 Jun 2023 11:24:47 +0100


>Suggestion: Use "setlocal" instead of "set" to avoid affecting other
>files. You only want to apply these options locally.

Done! Thanks Bram.

Steve Litt

未读,
2023年6月14日 16:44:192023/6/14
收件人 vim...@googlegroups.com
Tony Mechelynck said on Wed, 14 Jun 2023 10:03:44 +0200

>
>I think Tim's answer is right. Now for a bit of explanation, as found
>in the help for 'runtimepath' (in my gvim and with my 'guifont' this
>uses about two screenfuls of help text):

Thanks Tony! I wish somebody had told me about :h runtimepath twenty
years ago. It sure would have helped in my development and tech support
for VimOutliner.

[snip]

>• $VIM/vimfiles/ and its subdirectories other than after/ are
meant
>for system-wide scripts to be run before those distributed with Vim.
>These scripts are normally put there by a system administrator;



>• $VIMRUNTIME/ and its subdirectories contain scripts coming from the
>Vim distribution. Users and even system administrators should keep
>hands off them because any user's changes there will disappear the
>next time the Vim runtime files are updated;

Oh oh. See following command line session:

==================================================
[slitt@mydesk .vim]$ echo $VIMRUNTIME

[slitt@mydesk .vim]$ echo $VIM

[slitt@mydesk .vim]$
==================================================

I'll be studying :h runtimepath to make me more proficient with Vim.
Thanks for showing it to me.

Tim Chase

未读,
2023年6月14日 17:14:492023/6/14
收件人 vim...@googlegroups.com
On 2023-06-14 16:44, Steve Litt wrote:
> >??? $VIMRUNTIME/ and its subdirectories contain scripts coming from the
[snip
> Oh oh. See following command line session:
>
> ==================================================
> [slitt@mydesk .vim]$ echo $VIMRUNTIME
>
> [slitt@mydesk .vim]$ echo $VIM
>
> [slitt@mydesk .vim]$
> ==================================================

They're set internally in vim:

$ vim
:echo $VIMRUNTIME
/usr/local/share/vim/vim90

-tim





Steve Litt

未读,
2023年6月15日 02:25:182023/6/15
收件人 vim...@googlegroups.com
Tim Chase said on Wed, 14 Jun 2023 16:14:44 -0500
Thanks Tim,

I confirmed that you're correct. Until now, when I see a variable
beginning with a dollar sign I think either shellscript or Perl.
回复全部
回复作者
转发
0 个新帖子