Vim Keyword Completion - c

How do I tell the Vim editor about my include files path so that it can auto complete the function names when I press CTRL+N?
For example, I have a C program like below:
#include<stdio.h>
int main()
{
sca // here I press control+N, it does not complete to scanf
}

In your .vimrc, add the paths to your .vimrc:
set path+=/usr/include/**
set path+=/my_include_dir/include
set path+=/my_include_dir/srclib/apr/**
set path+=/my_other_include_dir/srclib/apr-util/**
** means all sub-directories.
* means all contained directories
. means all files in the directory of the found file
+= means prepend to existing path (iirc)
You can check the paths as well by opening your file and then entering
:checkpath
This will give you a list of all included files that are missing. N.B. It doesn't seem to handle preprocessor directives, so you will get some false positives. Entering
:checkpath!
Will give a complete list of found and missing include files.

Also, Important to note there are many completion functions.
^x ^o = "omnicomplete"
^x ^i = "included-files completion"
^x ^f = "path completion"
^x ^l = "Complete this line using one that looks the same"
see
:help ins-completion
for more.

Vim might also know the path already, if the files are in a standard location.
<C-n> uses the 'complete' option and the flag i scans included files. To add i to 'complete':
set complete+=i
you can also get a tags file from the symbols you want completed, which you can use with:
set complete+=t

Related

Using defines in Makefile.options file as a condition in Makefile variables

I am using clearmake and I am trying to do the following:
I have a Makefile.fast.options file that I use in my clearmake command. In there I have a USERFLAGS = -DFAST
and in another options file I don't have -DFAST in there (Makefile.slow.options).
In the actual Makefile, if FAST is defined, I want to set the output binary name to one name, or else I want to set it to another name. (If FAST is defined, I want the output to have .fast in the name, or else I want .slow.)
Is it possible to do this? perhaps I am missing a much easier method for using an options file to determine output file name?
I was also thinking of defining the filename in the makefile options file, seems much easier:
FILENAME = File.Fast
but I want to use the options file to override a definition of FILENAME thats in the makefile itself.. so, if FILENAME is set in the options file use it, or else use the one in the makefile.. is this possible?
You cannot just change the name of the file you build. You have to actually change the name of the target in the rule in the makefile. This means that the target name needs to be variable. The way you choose to make it variable is up to you.
If you're already including different options files based on fast vs. slow, then the simplest and most obvious way is to set the variable in those options files. That's the way I would recommend.
If you want to do it based on the value of USERFLAGS, you could do something like this:
ifeq ($(filter -DFAST,$(USERFLAGS)),-DFAST)
FILENAME = File.fast
else
FILENAME = File.slow
endif
But, this seems more complex and difficult to read and understand (to me).

How to remove specific characters from a file name?

I have bunch of files that need to have a (.) dot removed from the file-name. Eg. "Mr.-John-Smith.jpg" to "Mr-John-Smith.jpg". I don't have real experience with programming and know only html/css and a little javascript. I found another identical question here on stackoverflow, but what I gathered it was fixed on linux system and BASH was used.
Anyways, if anyone could provide me a tutorial on which program to use for this and what code to execute in that program to make it happen I'd be grateful.
if you are using a windows environment (which i guess you do)
you can download this free utility to mass change file names !
main page :
http://www.bulkrenameutility.co.uk/Main_Intro.php
download page :
http://www.bulkrenameutility.co.uk/Download.php
its easy to use
enjoy
If your file names in a file...
1- Open Microsoft Word or any text editor. Press ctrl+h and then search "." without quotes then replace it with blank character.
2- It will remove all dots, again bring "." to your file extention such as .jpg , .png searh your file extention for example "jpg" and replace it with ".jpg"
It will works %100, i am using this method everytime.
if they are not in a file and if you want do somethings in your operation systems' file system
Try this program. It is very useful for this operation;
Download
To remove all except the extension dot from all files in a directory, you can use PowerShell that comes with newer versions of Windows, and can be downloaded for older versions;
Line breaks inserted for readability, this should go on one line;
PS> dir | rename-item -newname {
[System.IO.Path]::GetFileNameWithoutExtension($_.name).Replace(".","") +
[System.IO.Path]::GetExtension($_.name); }
What it does is to take the file name without an extension and remove all dots in it, and then add back the extension. It then renames the file to the resulting name.
This will change for example do.it.now to doit.now, or in your case, Mr.-John-Smith.jpg to Mr-John-Smith.jpg.

How to replace text with current filename in VIM?

I suppose my question in not that clear but let me try to explain it here.
Let's suppose I have opened a file named myfilename.java with the below content
public class test{
}
Now, what I want is to replace test with myfilename. Now to get the filename in vim I used :echo expand('%:r') which gave me myfilename.
Now, my question is how to do I use the above output and replace test with it and map it to a key for future use. What I need is may be something like:
:%s/test/above_output_from_command/g
You need to add \= to tell Vim you're trying to call a function:
:%s/test/\=expand('%:r')/g
See :help sub-replace-expression.
For my application, I ended up using a keybound macro (not sure what the VIM) name for this is) that did the edit I want and simply inserted the filename where I wanted it:
:nmap <F5> 0d$:put =expand('%:p:t')^M0ipackage ^[$a;^[
In my case, I wanted to insert the name of the containint directory instead of the file, so I used:
:nmap <F5> 0d$:put =expand('%:p:h:t')^M0ipackage ^[$a;^[
The 0d$ deletes the contents of the current line, :put =expand('%:p:t')^M inserts the filename, and the remaining commands edit the line around the command to produce something like
package containing_directory;
on the current line.

How to fix "unable to open stdio.h in Turbo C" error?

Whenever I compile my program, I get the error above.
If you have problems like that, first of all your TC folder put in to the C:..drive.
after completing installation open turbo c blue screen.
there is a OPTIONS > Directories ..in that you can see for option to set up path..
include directories..you can set path there now.. C:\TC\INCUDE
libraries Directories..you can set path there...C:\TC\LIB
if you want to store your output in BIN then you can set..C:\TC\BIN..otherwise you can set another path where you want to store your output..
Finally you can give OK and finished processes..
It will now work properly
Do this: Open your turboc2 folder you have tc.exe file inside, beside this file you find another file as named as ' tcinst.exe ' open it.
You will see the installation menu:
select as-- > Option > Directory > Include directory
Here you have to change the path of the directory to the path where your INCLUDE folder is located. Same way change the path to library directory also over restart your tc.exe.
Check if you have anything like those stdio.h file and other header files under INCLUDE folder and LIB folder. LIB contains some files. In my case, I had the same issue but both of these folder were blank.. good to know.
Steps:
Press: ALT + O + D (i.e. press ATL (keep pressed) and then O english character) and then D).
You'll see a popup window.
This window will have values for INCLUDE and LIB directories. The by default value for these two boxes in the popup window are: Drive leter where you installed TC... i.e. C:\ or D:\ or whatever followed by the path for INCLUDE and LIB folder. So, in my case,
INCLUDE box was set to: "C:\TC\INCLUDE" and LIB directory value box was set to: "C:\TC\LIB" (without quotes).
Steps to resolve:
Press ALT + C.
Set your current directory as C:\TC\BGI
Press ALT + O + D, and put ../INCLUDE and ../LIB in Include/Lib directory values.
and now... when you'll run your progress, you'll say thanks to me. I like the archduchess C fractal graphics that I'm running on DOS Turbo C right now. Lol.
Go to OPTIONS tab then select directories option then enter the particular path where your turbo c folder exists.
Enter the path in all the four message boxes and it would start working like it did in my case. I have TurboC3 and all the files were together in one common root folder.
Check your environment include path. The file is not in the locations pointed by that environment variable.
Well, I've been working backshift just spent about 6 hours trying to figure this out.
All of the above information led to this conclusion along with a single line in dos prompt screen, when I exited the editor, go to the dos prompt my C: drive is mounted.
I did a dir search and what I found was: the way in which I had mounted the C drive initially looked like this
mount c: /
and my dir did not list all files on the C drive only files within the turboc++ folder.
From that I had drawn the conclusion that my directories should look like:
c:\include
not
c:\turboc++\tc\include
or
c:\tc\include
The real problem was the nature in which I had mounted the drive.
Hope this helps someone.
b.mac
Since you did not mention which version of Turbo C this method below will cover both v2 and v3.
Click on 'Options', 'Directories', enter the proper location for the Include and Lib directories.
On most systems, you'd have to be trying fairly hard not to find '<stdio.h>', to the point where the first reaction is "is <stdio.h> installed". So, I'd be looking to see if the file exists in a plausible location. If not, then your installation of Turbo C is broken; reinstall. If you can find it, then you will have to establish why the compiler is not searching for it in the right place - what are the compiler options you've specified and where is the compiler searching for its headers (and why isn't it searching where the header is).
Make sure the folder with the standard header files is in the projects path.
I don't know where this is in Turbo C, but I would think there's a way of doing this.
First check whether the folder name is right or wrong since while you copying to one folder from other accidently it takes other folder address eg it take C instead of F So from OPTION>DIRECTORY change the folder name
Just Re install the turbo C++ from your Computer and install again in the Directory C:\TC\ Folder.
Again The Problem exists ,then change the directory from FILE>>CHANGE DIRECTORY to C:\TC\BIN\

How to delete files with exclamation marks! using emacs' delete-file

I'm trying to make emacs' delete-file function delete files with exclamation marks in their names.
The particular use case is that I have set emacs to save all backup files in a single directory and to delete old backup files. However, when all backup files are placed in one directory, the directory separator / is replaced with !.
When delete-file is called on a file with an exclamation mark in its name, it returns zero and the file is not deleted. It doesn't signal any error. Normally, delete-file returns nil. Anyway, emacs' backup system uses delete-file for deletion, and I'd rather not redefine the entire function just to change a single line.
I've tried backslashing the exclamation marks and shell-quoting the filename string, and neither has worked. I found out that something in my config is causing this, but I haven't figured out what yet. I have tracked the source of the problem to my custom system-move-file-to-trash function, which I now have to debug.
So, how can I make this work?
Emacs version:
GNU Emacs 23.1.50.1
emacs-snapshot:
Installed: 1:20090730-1~jaunty1
M-x delete-file
Then just enter the name of the file, don't escape anything, just the name,
!home!blah!filename
and it just works. And the same goes for the lisp invocation,
(delete-file "!home!blah!filename")
I found the answer. My custom system-move-file-to-trash function, which delete-file will automatically use, inappropriately called shell-quote-argument on the file name. Apparently arguments to a command run using call-process do not need to be shell-quoted.

Resources