If you are using vim as editor and you are using vim inside a pseudo-terminal such as PuTTY, you might have less trouble with copy and paste function as you can use your mouse to highlight text, copy, and paste it inside the file.
However, if you have difficulty copying multiple lines in vim without access to mouse, or in tty, you might want to utilize the command ‘v’ or ‘V’.
To yank (copy) multiple lines:
1) Place the cursor on the first position of the first line you want to yank.
2) In vim command mode, press ‘v’ (without the quotes). You will notice that the message “– VISUAL –” will appear on the lower left part of the screen. This is an indicator that you are now in ‘Visual’ mode.
3) Use your arrow keys to move the cursor to highlight the lines of texts you want to manipulate.
4) After highlighting, press the ‘y’ key to yank (copy) the highlighted lines. You will notice the message similar to “9 lines yanked” on the lower left side of the screen. This means you have successfully copied the lines and ready to be pasted!
5) Place your cursor on the line you want to insert your copied lines to and press ‘p’ to paste below the cursor, or ‘P’ to paste above the cursor.
If you would rather cut the lines, press ‘d’ instead of ‘y’.
* Downloadable from http://oss.oracle.com/projects/compat-oracle/files/Enterprise_Linux/
In vim, you can run commands to simplify tasks. One case is to replace spaces with newline, or any character.
Inside vim, go to command mode by pressing the ESC key. Then enter the following command:
This will substitute (%s) spaces (\s) with return or newline (\r) and continue the replacement until end of line (g).
This is the command to use if you need to replace newline with spaces:
This will substitute (%s) newline (\n) with space (\s) and continue the replacement until end of line (g).
You may notice that newline and return characters are used differently and not interchangeable. This is because \r means ‘carriage return’ and if ever you had one of those typewriting classes wherein you learn how to use a typewriter (not a computer!), you will know what carriage return means. Anyway, in computing, it means the same thing, to move the cursor to the beginning of the line. Although it means almost the same, newline or \n does things differently. Newline character, or ‘line feed’, instructs the cursor to move to the next line.
So how is this relevant to the vim commands above?
When the user presses the ‘Enter’ key, the equivalent command is actually ‘CR-LF’, a combination of carriage return (CR) and line feed (LF)on Windows systems. In Linux systems, the ‘Enter’ key is just ‘LF’, it is understood that you want the cursor the start at the beginning of the line.
However, in replacing \n and \r characters in vim, these two are not interchangeable. If you need to add line feed, use the CR character, \r. If you need to remove the line feed, use the LF \n character.
In some cases, you need the capability of running an X server without installing an X server on your Linux machine. This can be done by utilizing the capability of SSH to forward X11 connections to a machine that runs an X server for Windows such as Hummingbird Exceed.
To start off, we need to install the packages we need for this to work. Run this command as root:
# yum -y install xorg-x11-server-Xorg.x86_64 xorg-x11-server-common.x86_64 xauth xterm openssh-server
After installing the packages, start configuring your Linux machine for X11 Forwarding.
1. Enable X11 Forwarding on SSH server by running the following commands as root:
# /bin/sed -i '/X11Forwarding/s/no/yes/' /etc/ssh/sshd_config
# /etc/init.d/sshd restart
2. Open another session and edit PuTTY profile to allow X11 forwarding. On your PuTTY configuration, go to Connection -> SSH -> X11 and tick the box Enable X11 forwarding.
3. In the X display location field, type localhost:0.0
4. Navigate back to Session and enter the hostname of your Linux machine. Click Open.
5. Login using your username and password. Once logged in, you may notice a message similar to this:
/usr/bin/xauth: creating new authority file /home/r19/.Xauthority
7. At this point, you will now be able to forward X11 to your desktop. Run your X11 server for Windows, in this example, we use Hummingbird Exceed.
8. Start any program that uses X11, xterm is a good program to use.
At this point, you should be able to see an X11 window on your Windows desktop.
If you are new to Linux, you are most likely to encounter libraries, which can be either static or shared.
But what are libraries?
When someone writes a program, object codes are used inside these programs. Sometimes, these object codes are repeatedly used, hence it would be more practical to create an archive of these common functions than write the same function again and again. The archives containing these common functions are called libraries, therefore, libraries are object codes grouped together into one entity. There are two types of libraries, it can either be static or shared.
Static libraries are libraries that is, well, statically linked and copied into the application. Basically, it means that the object codes are available only to the application that calls these codes, therefore if you have ten programs running, you will need a copy of objects for each program as static libraries are not shared to another program.
Shared libraries are object codes that are shared by and common among many programs. This means that a shared library can be referenced by any program that can access the library.
Advantages and Disadvantages
Static libraries require that each program has a copy of the objects, therefore it does not have dependency problems with shared libraries. A shared library can have this issue, for example, if someone has updated the library, it can break another program that uses the same library. Hence, it is important to make sure that the shared library remains compatible to all the programs that uses it.
Shared libraries minimizes the size of an application for it does not have to come with the common libraries, an advantage over static linking where all the libraries it needs are included in the application.
Shared libraries can also utilize a kind of linking called dynamic linking. Dynamic linking basically means that the libraries are called during the application loads or executes. These types of libraries are called dynamic shared objects or DSO, these libraries are linked by a linker, ld.so in Linux systems.
Subscribe to Email Feeds
- Vim: How to Copy Multiple Lines
- Required Packages for Oracle 11gR2 on Red Hat Enterprise Linux 6
- How Replace Space with Newline in Vim
- 3ix Web Hosting Complaints | First Time WebHosting on Backspace Key Not Working in PuTTY
- 3ix Web Hosting Complaints | First WebHosting on Backspace Key Not Working in PuTTY
- Cheap Web Hosting 3ix | Best in Webhosting on Cebu Pacific Sucks
- 3ix Web Hosting | Best in Webhosting on See Actual Street Pictures with Google Street
- 3ix Web Hosting Complaints – Raw Ask on Cebu Pacific Sucks