View Full Version : vim
graudeejs
February 9th, 2009, 23:18
Today I had some time... i decided to dedicate it to study some vim.
Now after few hours of reading, I announce vim to be my favorite text editor.
It's so flexible.... uhhhh
How could i live without it so long????
hydra
February 10th, 2009, 00:06
Better later than never :)
hitest
February 10th, 2009, 01:15
I'm lazy, I use nano. :) So what is so good about vim? You now have me curious!
graudeejs
February 10th, 2009, 01:24
I don't think words can express this....
but reading usr_01.txt to usr_04.txt is a thing i advise...
so many great features, so many ways to combine commands, so easy to do this and that..... i'm shocked
Tomorrow i'm removing [my so far default editor] geany, and never use le again (I used to like it)
gnemmi
February 10th, 2009, 02:14
Here (http://www.penguinpower.com.ar/foro/viewtopic.php?t=1790&start=0) you can find some minor tricks, that I posted on a forum we have, to get an even better vim experience ..
The whole post is in spanish, but I think the examples are pretty simple to follow .. In case you need help on understanding what they mean, just mail me o sen a PM :)
By the way ... I never leave without this ones on my .vimrc:
set textwidth=0 " Don't wrap words by default
set ruler " Show the line and column numbers of the cursor
set nu " Show line numbers
set ts=4 "Tab space == 4 whitespaces
set sw=4
set et
colorscheme murphy
Regards
PS: press "i", then ctrl+v and then press esc to get "^[" .. the scape sequence .. :)
mjguzik
February 10th, 2009, 05:32
How about tricks in english? ;)
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
http://linuxgazette.net/152/srinivasan.html
hitest
February 10th, 2009, 05:41
I don't think words can express this....
but reading usr_01.txt to usr_04.txt is a thing i advise...
so many great features, so many ways to combine commands, so easy to do this and that..... i'm shocked
Tomorrow i'm removing [my so far default editor] geany, and never use le again (I used to like it)
Okay. Now you really have me curious, killasmurf86! Thank you, I've got some reading to do. :-) I'm looking forward to this!
graudeejs
February 10th, 2009, 06:08
Okay. Now you really have me curious, killasmurf86! Thank you, I've got some reading to do. :-) I'm looking forward to this!
here's my vimrc :
set nocompatible
syntax on
set nomodeline
set backspace=indent,eol,start
set ruler
set history=50
set showcmd
set incsearch
set tabstop=4
set expandtab
set shiftwidth=4
set number
set scrolloff=5
set sidescrolloff=10
set incsearch
set wrapscan
set autoindent
set title
set hlg=en
set si
set backupdir=/home/killasmurf86/.bak
set backupext=.bak
set patchmode=.orig
set writebackup
set autoread
set enc=utf-8
set noautowrite
i made parts in bold that you want in your .vimrc already, especially syntax highlighting [you really want it, lot easier to read and navigate manual]
anemos
February 10th, 2009, 08:59
set nocompatible
This is redundant when you do have a .vimrc file.
See this (http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/) link for a biiiiiiig variety of nice schemes.
waterstof
February 10th, 2009, 09:08
After installing vim , this will get you on your way:
vimtutor
a tutorial oriented towards praxis! A very good one.
gnemmi
February 10th, 2009, 12:49
set ts=4 == set tabstop=4
set sw=4 == set shiftwidth=4
set nu == set number
set et == set expandtab
and so forth ... ;)
mjguzik: have you read my thread?? it has nothing to do with what you posted :s
fonz
February 11th, 2009, 14:35
Now after few hours of reading, I announce vim to be my favorite text editor.
Welcome to the club :beer Took you long enough though ;)
hitest
February 11th, 2009, 16:29
Thanks for the tips, gentlemen. :)
fonz
February 11th, 2009, 16:53
set ts=4 == set tabstop=4
set sw=4 == set shiftwidth=4
set nu == set number
set et == set expandtab
The set number thing is kinda debatable. I can imagine that people like it, but personally I don't.
One other thing: if you don't like the way vim's auto-indentation works with C code, disabling the indentexpr variable (:set indentexpr=) might make your life easier.
Alphons
gnemmi
February 12th, 2009, 13:56
I like "set nu" ...
Take this code .. main.c
1 #include<stdio.h>
2
3 int main(){
4
5 /* a comment in here ... */
6
7 int a = 1;
8 char something{} = "Something to print";
9
10 printf("%s :%d\n", something, a);
11
12 return 0;
13 }
14
compile it and, of course ... it won't ... I forgot my finger pressing the "shift" key while I typed "[]" on line "8" ...
[gonzalo@inferna ~]% gcc -Wall -pedantic -O2 -o test main.c
main.c: In function 'main':
main.c:8: warning: ISO C forbids nested functions
main.c:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
main.c:8: error: expected expression before '=' token
main.c:10: error: 'something' undeclared (first use in this function)
main.c:10: error: (Each undeclared identifier is reported only once
main.c:10: error: for each function it appears in.)
now .. just issue:
[gonzalo@inferna ~]% vim +8 main.c
and vim will open main.c and position the cursor on line 8, all at once ...
"set nu" helps me get a visual check on whether the cursor jumped straight to line 8 or not :)
It might seem trivial in this example .. but on 670 lines of perl voodoo .. it really helps :D
Regards
fonz
February 12th, 2009, 19:54
I like "set nu" ...
[snip]
now .. just issue:
[gonzalo@inferna ~]% vim +8 main.c
Like I said: I can imagine that you like it and you give a good example of why you do, but personally I don't like it that much because all those line numbers are a tad too cluttering/distracting for my taste. I'd rather just "set ruler". But hey, to each his own and I'm sure some people will look at your example and go: "Hey, that's kinda neat!" I just won't be one of them, that's all.
Happy coding,
Alphons
cajunman4life
February 13th, 2009, 16:07
As an alternative to "set nu", I have the following:
nmap <C-N><C-N> :set invnumber<CR>
So if I want line numbers, I press ctrl+n twice. To get rid of them again, ctrl+n twice again.
fonz
February 13th, 2009, 21:49
As an alternative to "set nu", I have the following:
nmap <C-N><C-N> :set invnumber<CR>
So if I want line numbers, I press ctrl+n twice. To get rid of them again, ctrl+n twice again.
<SouthPark>You know, I think I learned something today.</SouthPark>
Alphons
lme@
February 14th, 2009, 23:07
[gonzalo@inferna ~]% vim +8 main.c
and vim will open main.c and position the cursor on line 8, all at once ...
"set nu" helps me get a visual check on whether the cursor jumped straight to line 8 or not :)
It might seem trivial in this example .. but on 670 lines of perl voodoo .. it really helps :D
Even better is, when you have a Makefile in the working directory. You type :make and if you get an error, vim directly goes to the line where the error was found.
gnemmi
February 15th, 2009, 00:09
Sure thing !
But that was harder to demonstrate in here :(
rliegh
February 21st, 2009, 05:53
I prefer (n)vi any day of the week, myself.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.
0