vim-addon-local-vimrc

Configuration: these are the defaults:

let g:local_vimrc = {'names':['.vimrc'],'hash_fun':'LVRHashOfFile'}

Features:

  • When Vim starts up, every directory from root to the directory of the file is traversed and special files such as .(local-)vimrc files are sourced

  • Because you don't want to run untrusted code by accident, this plugin calculates a hash before sourcing. If its unknown you must confirm sourcing the file. The hash is updated automatically if you write a local vimrc file.

  • if you change a directory and edit a file the local vimrc files are resourced

USAGE:

create a .vimrc in your project directory. To make sure it's working, add: echo "this file is being sourced by vim"

Sample local .vimrc

augroup LOCAL_SETUP
  " using vim-addon-sql providing alias aware SQL completion for .sql files and PHP:
  autocmd BufRead,BufNewFile *.sql,*.php call vim_addon_sql#Connect('mysql',{'database':'DATABASE', 'user':'USER', 'password' : 'PASSWORD'})

  " for php use tab as indentation character. Display a tab as 4 spaces:
  " autocmd BufRead,BufNewFile *.php set noexpandtab| set tabstop=4 | set sw=4
  autocmd FileType php setlocal noexpandtab| setlocal tabstop=4 | setlocal sw=4

  " hint: for indentation settings modelines can be an alternative as well as
  " various plugins trying to set vim's indentation based on file contents.
augroup end

KISS: If you need filetype support write au commands into the local vimrc.

Yes I know that there are already a couple of existing similar plugins. But I they work for filetypes only (why?) and they don't verify file contents.

Alternatives

directory local .vimrc without walking up directory tree using vim builtin 'exrc' option: :h 'exrc' :h 'secure' but 'secure' is not very secure, eg echo system('cat .vimrc') is executed unless the file belongs to a different owner..

contributors

Thiago de Arruda (github.com/tarruba)



vim-addon-local-vimrc

配置:这些是默认值:

let g:local_vimrc = {'names':['.vimrc'],'hash_fun':'LVRHashOfFile'}

功能:

  • 当Vim启动时,每个目录从根目录到文件的目录 被遍历,特殊文件,如。(local-)vimrc文件来源

  • 因为你不想意外运行不受信任的代码,这个插件 在采购之前计算哈希。如果不确定,您必须确认采购 文件。如果您编写本地vimrc文件,则哈希将自动更新。

  • 如果您更改目录并编辑本地vimrc文件资源的文件

USAGE:

在您的项目目录中创建一个.vimrc。 为了确保它正常工作,添加:echo这个文件是由vim来源

Sample local .vimrc

augroup LOCAL_SETUP
  " using vim-addon-sql providing alias aware SQL completion for .sql files and PHP:
  autocmd BufRead,BufNewFile .sql,.php call vim_addon_sql#Connect('mysql',{'database':'DATABASE', 'user':'USER', 'password' : 'PASSWORD'})

" for php use tab as indentation character. Display a tab as 4 spaces: " autocmd BufRead,BufNewFile *.php set noexpandtab| set tabstop=4 | set sw=4 autocmd FileType php setlocal noexpandtab| setlocal tabstop=4 | setlocal sw=4

" hint: for indentation settings modelines can be an alternative as well as " various plugins trying to set vim's indentation based on file contents. augroup end

KISS:如果您需要filetype支持将au au命令写入本地vimrc。

是的,我知道已经有几个现有的类似的插件。 但是我只为文件类型工作(为什么?),并且它们不会验证文件内容。

Alternatives

目录本地.vimrc没有走路目录树使用vim内建’exrc’选项: :h’exrc’ :h’secure’ 但是’安全’不是很安全,例如echo系统(’cat .vimrc’)被执行 除非文件属于不同的所有者。

contributors

Thiago de Arruda(github.com/tarruba)




相关问题推荐