Vim options

One week back while Pramode Sir was teaching us Java he told us to
use abbreviations in Vim for those things like “System.out.println” and
so…….
As I was unaware of those beautiful features provided by vim I started
to explore those and found many cool options of vim. Some of them are
listed below.

Some word searching methods:-

Using star ‘*’ key:-
In the normal mode using the * key would search for the word under
which the cursor currently resides. This is similar to searching the
word using ‘\’ in escape mode… I hope you all know how that works.

Using hash ‘#’ key:-
The * key searches the word from the current cursor position to the
end of the text while # key searches from current position to the top
of the text.

:set incsearch
This option helps you to move the cursor to the matched string.
Pressing Enter key completes the search and Escape to cancel the
search.

:set hlsearch
When this option is set then all the matched string are highlighted
in yellow shade

:set nohlsearch
This is to disable highlighting completly.

You could switch the case of characters using commands “~”,”gu”,”gU”

~ – switch case of character under cursor
g~~ – switch case of current line
guu – make the current line to lowercase
gUU – make the current line to uppercase
guaw- make current word lower case
gUaw- make current word upper case

Using Abbreviations:-

To define abbreviations use ab[breviate] command…
Example:-
:ab gnu gnu’s not unix – Whenever you type gnu followed by a space
tab or esc vim expands it into ‘gnu’s not
unix’

:ab – lists all defined abbreviations

:unab gnu – removes gnu from abbreviated list

:abc – clears all abbreviations

Typing Cntl-V after the last character of the abbreviation avoids
expansion of the abbreviation

Browsing through a text:-

Using appropriate commands we could save a lot of time browsing
the text rather than using the up and dow keys.

e – moves to the end of the word
w – moves to the beginning of the word
b – moves backward to the beginning of the word

( – jump forward one sentence
) – jump backward one sentence

{ – jump forward one paragraph
} – jump backward one paragraph

G – jump to end of file
1G – jump to beginning of the file
10G – jump to line 10

” – return back to the line where cursor was before the last jump

Vim – A perfect editor for C-programmers

Word Completion:
After writing the beginning characters of a word and then typing
keys Cntl-N or Cntl-P may completes the word. Invoke the key once and
vim finds the first match in the text so far and fills. If no match
is found then it will search for it in the included files.

Using % key.
% key can be used for
1. To match closing and opening paranthesis,square and curly brackets
([{}])
2. To jump to start and end of C-style comments (/* and */)
3. To jump to matching #if, #ifdef, #else, #elif, #endif C preprocessor
conditionals

Jumping to start and end of code bloc:-

To jump to the beginning of a C code block (while, switch, if etc),
use the [{ command.

To jump to the end of a C code block (while, switch, if etc),
use the ]} command.

The above two commands will work from anywhere inside the code
block.

To jump to the beginning of a parenthesis use the [( command.

To jump to the end of a parenthesis use the ]) command.

Displaying a variable/macro definition

To display the definition of a variable, place the cursor on the
variable and use the [i command. To display a macro definition,
place the cursor on the macro name and use the [d command.

Jumping to the declaration of a local/global variable

‘gd’ command:
To jump to the declaration of a local variable in a C program,
position the cursor on the name of the variable and use the
gd command.

‘gD’ command:
To jump to the declaration of a global variable in a C program,
position the cursor on the name of the variable and use the
gD command.

There are much more cool and powerful techniques in vim which u could
get from the below mentioned site

Bye.

References:-

www.vim.org/tips/tip_search_results.php

This entry was posted in Uncategorized. Bookmark the permalink.

7 Responses to Vim options

  1. anonymous says:

    hello

  2. anonymous says:

    ok…so u blog as well and thats a neat one all that jargon…pretty much in java mood huh?! da yhis is leya and since i have no patience to open an id..ill leave..keep blogging!

  3. vivek_b says:

    Thank you Leya..

  4. anonymous says:

    hi vb
    by th way who is this leya?classmate?i think she is a puli!!got the impression after reading some other comment!!

  5. vivek_b says:

    Yup, you guessed rite.. she’s my classmate.. Considering Leya just as a puli is an insult to her.. Learn more about Leya here

  6. anonymous says:

    da who s dis anonymous????? njan ariyatha oru anonymous…….

  7. anonymous says:

    And who is this..???

Leave a Reply

Your email address will not be published. Required fields are marked *

one + 6 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>