How to set/unset options in Vim

Vim is a very powerful text editor and as such it has lots of options which allows you to configure it “just right” for you! In order to configure it you can set up values to its various options either in the current window you are working on or in configuration file so that every new instance launched will have common settings. This file is usually called vimrc and is located under your home catalog.

But what happens if you wish to reset the value of an option you have configured in this configuration file for just this window that you are currently working in? I found that to be more difficult than expected so, here is how you can:

  1. Start a clean instance of vim with all its default options that ignores all the settings in all the user defined configuration files
  2. Get the currently set options and their values
  3. Disable/reset options that I will call switches
  4. Reset any option to each default value (whatever that might be)
Continue reading “How to set/unset options in Vim”

How to create a symbolic link

A symbolic link is a “connection” we create between a location and a physical file or directory. The file or directory exists in a known location A in our system and we wish to create a connection to that location from a different location in our system B. An easy way to think of a symbolic link is like a shortcut from one location to another.

A symbolic link is created with the following command

ln -s TARGET NAME_OF_LINK

where ln is the basic unix command, the parameter -s specifies that we wish to create a symbolic link, TARGET should be replaced with the destination of our link and NAME_OF_LINK should be replaced with what we want our link to be named after.

Continue reading “How to create a symbolic link”

Value of an environment variable

If you wish to see the value of an environment variable the easiest way to do so is to print the contents of the variable in your shell. To do so you have to use the following command:

echo $var_name

If there is an environment variable defined named var_name then the above command will output its contents in standard output (your shell). If there is no variable with that name defined the above command will output an empty line. If you see var_name outputed in your shell you probably forgot to type in the $ sign before the name of your variable. Remember that echo simply echoes a string in standard output so if you do not specify that the string you typed is a variable ($ sign) then it will simply output your string.

Now if you do not exactly remember the name of your environment variable the easiest way to find out if it is defined or not would be to output all the environment variables defined and either move your way through the list like

printenv

or pipe the output to grep providing a part of the name of the variable like

printenv | grep name

Alternative to “Notes” for kde

I recently found an alternative to kde’s Desktop sticky notes which was most probably not made for that but none the less it does the trick and it allows you to have control of the location and storage of your notes.

You can use an editor and create a txt file that you will keep your notes in. The good thing is that since this is a file that you have created you can store it wherever you want on your local system and perhaps back it up as you would with every other file.  Then you can add a kde desktop widget called File watcher. As soon as you place your widget on your desktop it will only have a single button on it and clicking it will allow you to select the file you wish to “Watch” (check for changes or modifications). Here select your notes file by browsing to your directory.

After completing the steps described above you will have your notes displayed in the File watcher and whenever you update and save the file the widget will be updated automatically. If you wish to edit your file you don’t even have to browse to its location and edit it, you can simply right click on the widget and choose“Run the associated application” which will open your notes for editing. That’s it! Save and you are done…

Counting files in a directory

When browsing your directories command line on your linux box you might want to get a count of the files inside a particular directory. This turns out to be a very easy task and the only things you need to know are the | operator and two basic commands, called ls and wc.

Since you are browsing your directories command line I take it you already know ls (for listing directory contents) but you might not yet know wc!

So first you need to issue an ls -l command which will print on standard output (your terminal) a list of the files in your directory one file at each line. Then we need to pass that result as input to the wc command (which prints information about the lines in a file, or the words in a file etc.). So, we can do that in one line by writing:
ls -l | wc -l