Showing posts with label VIM. Show all posts
Showing posts with label VIM. Show all posts

2013-03-04

vim - improving vim skill by breaking arrow keys

Improving vim skill have a new way, "breaking" the arrow keys on the keyboard.

No No, not literally! Just disable them by assigning "no operation" to the arrow keys stroke. This will render your arrow keys useless when you're inside vim editor, thus forcing you to stick to h, j, k & l key to move around.



Put these into ~/.vimrc:
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>

If this is not dramatic enough, I foresee I'll put these in as well:
noremap h <NOP>
noremap j <NOP>
noremap k <NOP>
noremap l <NOP>

further forcing myself to use keys like "w", "b", "e", "ge", "W", "B", "E", "gE", "f", "F", "t", "T", ";" & ",". To decrypt those characters, check out ":help word" in vim editor.

Via here then here.

Adios!

2011-02-25

vim - How to stop vim creating "tilde" backup files

Vim, aka the Programmer's Editor, by default creates backup files (ends with a tilde character) whenever editing file. E.g. myfile~, another_file~, yet_another_file~ and etc.

After some time, this generates too many backup laying around the file system. Too messy. This is how to stop vim create these backup files :

2009-09-25

vim - Commenting multiple lines, block comment

Perl does not have block comment feature. The Acme::Comment module was the easiest way to make Perl do block commenting, with additional features, it allows customization of open & close punctuation mark.

Until yesterday, my first Perl code got some problem and had to seek help from the IRC channel perl-help @ irc.perl.org (these guys are really helpful, thanks dudes!). Just when they were helping me to solve the problem, Caelum tip me on how to block comment in Perl using vim. I thought it was a good idea as it doesn't need to load additional module to handle the block comment thing, which save some CPU processing.

Here it is :

2009-04-23

How to view file in read only mode

"view" is the editor "vim" or "vi" in read-only mode. The browsing capability is same as vim. It is an alternative to read a file other then using less or more.
e.g.
view some-text-file.txt

Ciao !!!

2009-04-19

vim - case insensitive search and occurrence or match operations

A short tip. For searching in vim, enter the "Command-line" mode by type a colon (":") in "Normal" mode (Esc twice at any time) and type "set ignorecase" for case-insensitive search.

e.g.
:set ignorecase

Additionally, for "next" occurrence or match, type "n" or "N" for "previous" occurred match.

Ciao !!!

2009-04-17

vim - basics of search and replace in substitute command mode

When cleaning up some config file with hundreds of lines, browsing up and down just to find the key word can be eye dazzling, in the pungent way. :)

The good thing about vim is, it is able to find any text you want using the "Search" command (/) in the "Normal" mode (Esc twice any time).

Some of the time, we need to change the search result with a new value. Be it slight change, addition or even removal, vim is definitely up to the job. To quote a few examples :

2009-03-19

vi or vim - Why the delete key, navigation keys (up, down, left, right), syntax color & a few more other are not working/missing ???

Ever wonder why vi behave weirdly after a new installation of Linux or BSD? Delete key turns the current character into capital, navigation keys adds a newline with random characters, Home & End key does nearly the same, syntax color no longer works (which is eye soring if reading along with a bunch of comments) & other frustration.

That's suppose to be.

Because the default vi (literally) that comes with the default installation is the stripped down version of vim. The usual vim that comes with the more comforting features are still around, just that it needs to be tweak. Or most, install.

2009-03-02

vim - cut / copy paste with indent intact nicely

System administration in Linux / BSD can never do without a text editor, and vim is definitely de-factor editor. vim is not only an text editor, it can be also a IDE (integrated development environment) and it is extremely light in resource. Just to mention a few of its features, syntax highlighting, auto indent, search & replace, copy/cut & paste & others. vim comes with all versions of linux & BSD, check your flavors documentation.

Problem :
copy / cut text from other apps (e.g. gedit, openoffice, kedit, abiword, textmate, notepad, textedit & other text editor) to vim often jumble up the space.