The introduction at the top mentions "See Toggle auto-indenting for code paste" and that tip has the correct way to do this. Sometimes you only need to paste some snippet of code, that already has indentation, so you can disable it only during the paste operation: Fritzophrenic ( talk) 18:23, Janu(UTC) Disabling auto indent temporarily to paste Insert a non commented line despite formatoptions.See the following for your problem with comment leaders, or do a search yourself for "comment leader" on the wiki or elsewhere: Presumably this refers to the comment leaders inserted automatically by Vim. (update - add this to your vimrc to block the autoindenting of comments - no other solution on this page works):-Īutocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o See :help 'filetype', and also VimTip1213. I think that - and correct me if I'm wrong - setting ft=php should offer indentation for PHP while leaving the HTML alone. Note that while 'smartindent' works decently for PHP, filetype indentation usually works better, even in this case. When wanted, enter the following to toggle the smartindent option, and show its current value: You may have disabled auto indenting in HTML files, but you would like auto indenting of your embedded PHP code. Here is a mapping so you can press F8 to disable auto indenting: The following is equivalent (it uses the abbreviated names in a single command): If you are editing a particular file and you want to prevent auto indenting within that file, enter: :verbose set ai? cin? cink? cino? si? inde? indk? To see the current indenting settings, and where they were set, enter: For either of these cases, put the following near the bottom of your vimrc to disable filetype based indentation:ĭisabling auto indent for the current file However, the filetype indent plugin on command may be included in a system-wide vimrc ( :help system-vimrc), or in the file vimrc_example.vim sourced from your vimrc. If you remove the indent keyword, none of your files will have file type based indentation rules applied. However, it's easy to disable all auto indents if wanted.Īctually, auto indentation is off by default, and if it is enabled on your system, that is because something has enabled it. The auto indentation provided for most languages is very helpful, and you should consider trying it. If you are not sure what that name is, edit a file where you want to remove auto indentation (for example, my.htm), then enter the following command to display the value of the ft ( filetype) option for the current buffer:ĭisabling file type based indentation for all file types You need to use the correct name for the file type ( html in the above). Auto indenting for the particular file type is disabled because well-behaved indent scripts do nothing if the buffer-local variable b:did_indent is defined (that variable indicates that the current buffer already has script-based indenting enabled). This creates a user-specific indent script which will be loaded before the file type indent script. You can disable auto indentation for particular files types the following example shows how to do this for html files.Ĭreate the file ~/.vim/indent/html.vim on Unix-based systems, or $HOME/vimfiles/indent/html.vim on Windows systems, containing the single line: You may like auto indenting in C programs, but dislike it when editing html files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |