Select the block of text:
1. Position the cursor at the beginning of the text you want to replace
2. Press v to enter visual mode. (or upper case V to select whole lines, or Ctrl-v for a vertical block).
3. Move the cursor to the end of the text to be replaced. (While selecting text, you can perform searches and other advanced movement, a feature that sets vim apart from most other editors.)
4. Press c. This deletes the selection and leaves you in insert mode.
5. Type your replacement text.
The selection is done in visual mode.
To cut (or copy) and paste using visual selection:
1. Position the cursor at the beginning of the text you want to cut/copy.
2. Press v to begin character-based visual selection (or upper case V to select whole lines, or Ctrl-v for a vertical block).
3. Move the cursor to the end of the text to be cut/copied. (While selecting text, you can perform searches and other advanced movement, a feature that sets vim apart from most other editors.)
4. Press d (as in “delete”) to cut, or y (as in “yank”, which I imagine meaning “yank so hard and fast that it leaves a copy behind”) to copy.
5. Move the cursor to the desired paste location.
6. Press p to paste after the cursor, or P to paste before it.
Bonus Tip: To replace the selected text with new text (to be entered by you), press c instead of d or y on step 4. This deletes the selection and leaves you in insert mode. Then, instead of (or prior to) steps 5-6, type your replacement text.
Recording is a really useful feature of Vim.
You start recording by pressing “Q” key followed by any other letter keystroke, and you can end it by typing “Q” again.
It records everything you type. You can then replay it simply by typing “@“ followed by the letter.
Record search, movement, replacement…
This is one of the best features of Vim.
One more thing to note is that you can hit any number before the “@“ to replay the recording that many times like (100@<letter>) will play your recorded actions 100 times.
To close a file, use the fclose() function.
int fclose( FILE *fp );
The function flushes any data still pending in the buffer to the file, closes the file, and releases any memory used for the stream’s input and output buffers. The fclose() function returns zero on success, or EOF if an error occurs.
When the program exits, all open field are closed automatically. Nonetheless, you should always close any file that you have finished processing. Otherwise, you risk losing data in the case of an abnormal program termination. Furthermore, there is a limit to the number of files that a program may have open at one time; the number of allowed open files is the value of the constant FOPEN_MAX.
To check out this value. we can do :
printf("Max # of open files = %d\n", FOPEN_MAX);
The program returns 16 on my platform.
Manipulate the nth bit of a int a
- get bit:
- a>>n & 1
- set bit:
- 1<<n | a
- clear bit:
~(1<<n) & a
A lot of the tutorials online teaching us to install and configure tightVncServer.
However, that is totally unnecessary, Ubuntu comes with vnc4server right out of the box (I’m using Ubuntu 12.04 LTS). And vnc4server is quite easy to configure.
Continue reading “How to setup VNC on Ubuntu Linux”
The Scenario is This:
I have a Bose Mini SoundLink bluetooth speaker and a headset connected to my MacBook. Normally you can only have one device making sound and can switch between them.
This is a native utility tool, Audio MIDI Setup, on OS X, that let you take advantage of multiple inputs and outputs.
Continue reading “How to Use Multiple Audio Outputs on Mac”
For more detailed explanation: refer to theGeekStuff blog
The most convenient way to know what each directory is about is to open Terminal and type this command:
/bin: where binary programs live.
/boot: special programs that start the system when you turn the machine on
/dev: all the “device” listings for hardware of every conceivable flavor, along with some “imaginary” devices
For most of the times, chances are that you can launch one application and right click on the icon in Launcher and click “Lock to Launcher” to make the application icon stay in Launcher for easy access.
However, there are a few programs that does not support Launcher.
After researching for a while, I found the answer on StackOverflow, but can’t locate the original post.
Here are the steps to manually make it happen.
First, create a .desktop file to the application (eclipse for example) in the applications directory:
Then, paste the following inside (don’t forget to edit Icon and Exec values):
Comment=Eclipse Integrated Development Environment
Icon=** something like /opt/eclipse/icon.xpm **
Exec= ** something like /opt/eclipse/eclipse **
Note: to locate your eclipse, issue this command:
Finally, drag the .desktop file onto the launcher.
Now you have it. Cheers!
I have run out of space on my Win8 virtual machine, which only assigned 15GB space when I created it. Is there an easy way to increase it to, say, 25GB? I can’t see any obvious option in VirtualBox settings.
Here is the solution:
Continue reading “How to increase the hard disk size of a VirtualBox virtual machine”