Perforce manual says that if you want to automatically expand RCS keywords in file contents, you have to specify some type for them (i.e. +k or +ko).
Is there a way to specify file type based on it's extension globally for the whole depot or its subdirectory?
For example, Subversion has such a feature called auto-props.
You can define a "typemap" which will automatically assign a default filetype based on extension, and hence have "text+ko" the default.
http://www.perforce.com/perforce/doc.current/manuals/cmdref/typemap.html
Related
I'm not sure if this is something that can be done in the Linux/Unix terminal, so I thought I'd ask.
For certain programs (unfortunately I can't think of any besides bibtex off the top of my head, which on tab auto-'extends' the .aux extension) when I'm finished typing out the file name (minus dot and extension) in front of it, I've noticed that if I hit tab it will 'auto-complete' the dot + file extension.
Is this something you can actually control somehow ? For example, if I wrote a bash script (we'll call it compile.sh) that only worked with *.tex files, I could do the following:
$ ./compile.sh nameOfProgram -- tab and autocomplete .tex extension --
Certainly it's not inherent to the bash script itself, but by some other means that recognizes I'm using said executable.
Sometimes, as is often the case while using LaTeX, there are multiple files with the same base name but different extensions in the same directory - I would like it to only accept that which has the predefined extension.
It is certainly possible to define a custom completion function for compile.sh which only matches *.tex files. Writing a good completion function is a broad task, but you can do something very simple with
# Add to your .bashrc file to enable in every shell, not just
# the current shell
complete -G '*.tex' compile.sh
which will only treat files matching *.tex as valid completions for any argument to compile.sh.
I am using Vim editor v7.4 .
I have a huge C Code library , and i make constant changes to it.
Is there a way ( before compilation) to know if a function i am adding to some file is defined for this file.
Thanks
I'm not sure to correctly understand your need. In my definition, when I add a function to a file, I add its definition, so it's defined. But when I'm using a function in a file, I only need its declaration. Then there is also the problem of being sure that a function defined in a translation unit is declared somewhere (privately in the same TU as a static function, or in a header file).
For the latter, I have a solution (that checks functions definitions and declarations are balanced in lh-cpp). For the case of being sure a function is declared in the UT it's used, it won't be that simple: we need to do the preprocessor work (and recursively follow includes) and search whether a function is indeed declared. It's not impossible, but it's best to have vim know the paths where header files are in order to look for them.
Look at a tool like exuberant ctags. It parses C-style files to find any identifier and store them in a tag file, so that each of them can be accessed quickly, inside Vim for example.
Once installed, in the shell command line, you have to create a tag file with this kind of command:
$ ctags *.c *.h
This will create an new file called tags, where all the c files and header files in the current directory are parsed. Please note that there are many options for this tool (like recursively include all lib headers, which can lead to a huge file, though), you may look at the doc for more details.
Once done, in Vim, there are several commands to use transparently the infos in this file. First check your current directory is the same as the tag file; then, to check if an identifier (like a function name) is already present in the tag file, you can use:
:ts myFunctionName
I don't think tag is a good enough solution to check whether function is defined. The flexibility of C syntax make it worse, because most tag tool is syntax-based other than semantics-based.
For example, at present, the most powerful code-completion plug-in for vim is
YouCompleteMe, which is semantic-based by virtue of Clang.
So IMHO, the answer to your question is: compile it!
In order to do compiling more convenience, you can add the following configuration in your .vimrc.
map <F6> :make install<CR>
After this, when you press F6, compiler will be launched to check your code.
When working with filetypes other than c I only get suggestion from all open buffers (using supertab). But when I hit Tab to do word completion in c filetypes I get suggestions from system wide C header files which are useless to me (specially when number of suggestions are more to navigate).
I don't think any of my plugins are interfering in this. I don't want suggestions from header files. Please, what can I do?
There are some default plugins interfering. The option 'complete' selects which completion sources you are interested in. The possible ones are:
current buffer
buffers from other windows
other loaded buffers that are in the buffer list
unloaded buffers that are in the buffer list
buffers that are not in the buffer list
files given with the 'dictionary' option
currently active spell checking (see spell)
files given with the 'thesaurus' option
additional dictionary files given in 'copmplete' option with behaviour similar to 'dictionary' and 'thesaurus'
current and included files
tags
The default setting is:
the current buffer
buffers in other windows
other loaded buffers
unloaded buffers
tags
included files
The last or the next-to-last item is interfering with your usage. The included files are searched based on options
'include' defines patter for finding include directives. The default value is appropriate for C files, so this completion mode kicks in in C (and C++) files and not much anywhere else.
'path' defines where the include files are searched. Check whether you have /usr/include there.
'tags' defines list of "tags" files to use by relative or absolute paths. You might have /usr/include/tags there.
You can disable these completions by either removing respective flags from 'complete' option or by removing /usr/include from 'path' and/or /usr/include/tags from 'tags'. The completion modes are default, but the paths shouldn't be (/usr/include/tags is a vi default, but not vim default, so it shouldn't be used if you've set 'nocompatible').
Note, that tags will always complete from all system files, since it uses an index of symbols, while include will only complete from actually (even indirectly) included files.
I use etags with vim on linux for source(*.c, *.h) code browsing. I have created a TAGS file bu giving command :
etags --members *.c *.h
TAGS file gets created but when I start browsing say one of the source files named 1.c which has a C structure variable defined and used in one of its function definitions(The structure name is a typedef in some other 1.h file). I open the file 1.c in vim and then I do CTRL - ] by placing cursor on that struct type, etags does not browse to the header file 1.h which has declaration of this structure.
This only happens when i have below line in my .vimrc, when i comment below two lines, etags based source browsing works fine.
set TAGS=./TAGS;$HOME
set tags=./tags;$HOME
I am trying to tell vim where to locate the TAGS file. starting from current folder till my home dir. What is incorrect here?
What is the correct syntax for above command?
Also does ctags/etags browsing with vim, show from where all a given function is called from?
If yes, what is the command to see that?
Locating tags file
Vim's settings are case-sensitive so set TAGS= is invalid. You must use set tags= in lowercase.
Vim will stop at the first match so you can't really expect it to search for a tag in tags and TAGS. These files can be searched in turn with:
set tags=./tags,./TAGS;$HOME " 1. tags, 2. TAGS, 3.… until $HOME
Also, search is not performed by etags, it's done by Vim itself.
Jumping to function calls
No, ctags and etags only index declarations. To jump to usage you'll need cscope
I installed a vimscript written by expert in this question.
But there is one problem in the script. When I restart the computer, the bookmarks saved by the script will disappear.
Is it possible to store the bookmarks to another file (e.g. mybookmarks.txt) instead of .viminfo file? Bookmarks stored in .viminfo disappear unpredictably.
Yes. Use the 'viminfo n' option.
From :he 'viminfo':
Name of the viminfo file. The name must immediately follow
the 'n'. Must be the last one! If the "-i" argument was
given when starting Vim, that file name overrides the one
given here with 'viminfo'. Environment variables are expanded
when opening the file, not when setting the option.
Since it seems like a good tool in general, I extracted it to a plugin: http://www.vim.org/scripts/script.php?script_id=3826. This would store bookmarks only, regardless of viminfo settings, in ~/.vim_bookmarks. The filename is configurable by changing g:simple_bookmarks_filename.
Since it's a full blown plugin now, you can send bug reports on the issue tracker, so if it's not working quite right, let me know.
Cheers.