code formatting

12 views
Skip to first unread message

olga30dec

unread,
Dec 10, 2021, 5:35:39 AM12/10/21
to Nvim-R
Hi, 

Apologies if it has been asked or answered already.  How do I enable code formatting (e.g. correct alignment of brackets, indentation within loops, etc).  

At the moment my .vimrc contains:

if has('filetype')
filetype indent plugin on
endif

But it does not seem to do anything useful. 

Thanks,
Olga

Jakson Alves de Aquino

unread,
Dec 10, 2021, 5:50:23 AM12/10/21
to Nvim-R
Delete the lines

if has('filetype')
endif

and put at the very beginning of your vimrc:

filetype indent plugin on
syntax on

Neovim doesn't require these lines in its init.vim because syntax highlighting and indentation are enabled by default.

olga30dec

unread,
Dec 10, 2021, 6:44:44 AM12/10/21
to Nvim-R
Thank you.  And how can I force formatting code which is already written?

Jakson Alves de Aquino

unread,
Dec 10, 2021, 6:51:28 AM12/10/21
to Nvim-R
Please, look for "Rformat" in the documentation.

olga30dec

unread,
Dec 10, 2021, 3:01:30 PM12/10/21
to Nvim-R
Thanks for pointing out, I will.
Reply all
Reply to author
Forward
0 new messages