Thread: VIM: The (un)official thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    Thumbs up VIM: The (un)official thread

    I noticed in this other thread a lot of people of people mentioned vim, and usage problems with vim. I'm not going to do a complete review, but I will say I really believe it is the greatest piece of software of all time.

    It's also the most poorly documented, so what I did want to do was start a new thread here in the "Product Review" board where people could ask stuff like "How can I see the value of a defined variable?" (the answer is here; "[i" works in escape mode)

    I'm sure there are some other programming software products around that could have an even more popular thread, but I'm not going to start any of them

    Here's the wikipedia entry for the curious:
    http://en.wikipedia.org/wiki/Vim_(text_editor)
    And the actual homepage is welcome home : vim online.

    I recommend against the use of the GUI. There is nothing wrong with it, but it is unnecessary and the functionality cannot be improved upon with tradition pull down menus and tabs (learn to use a keyboard, you are a computer programmer!). Plus, there is nothing like being able to use your absolute favourite tool even when you don't have a graphical desktop, and not have to remember how to get things done without a mouse to click and point things at. If you are new to the whole concept, two commands which work in escape mode that you might want to get to know are
    :split
    This splits the window in half horizontally, and if you include a filename loads it. You can also split the window unevenly (try ":help split"). To move back and forth, use ctrl-ww.
    :e #
    This will reload the last file, handy for flipping back and forth.

    Vim is standard on almost all unix derived operating systems including linux, and available for all of them (including MAC OS). There is even a windows and DOS version. However, the package included with your linux distro probably leaves a lot to be desired. It is easy to compile from source, however (choose the "huge" option to get the most functionality). A quick test of your installation is to try "vim --remote": you should be able to type:
    vim --remote mycode.c
    to send a file to the currently running (or first) instance of vim in any terminal anywhere on your desktop. This is very handy since you can add this command to your filebrowser, and just have one fullscreen, non-GUI vim in a terminal somewhere. If it doesn't work, your install doesn't have all the vim features and you should uninstall it and build from the source.

    Here's a simple ~/.vimrc that demonstrates some basic and essential configuration (the double quote " starts a comment):
    Code:
    " .vimrc
    " syntax highlighting, line numbering, etc on by default
    :syntax enable
    set number
    set nowrap
    set bs=indent,eol,start         " allow backspacing over everything in insert mode
    
    " you probably want all the syntax colors to work in your terminal
    " here's how to set them for contrast
    " numbers and color names are interchangable
    hi Statement ctermfg=7
    hi LineNr ctermbg=0 ctermfg=4
    hi Comment ctermbg=7 ctermfg=darkblue
    hi PreProc cterm=bold
    hi Type ctermfg=6
    hi Identifier ctermfg=2
    hi Number cterm=underline ctermfg=6
    hi Conditional cterm=bold ctermfg=3
    hi Repeat cterm=bold ctermfg=1
    hi Constant ctermfg=3
    hi StatusLine cterm=bold ctermfg=green ctermbg=darkmagenta
    hi StatusLineNC ctermfg=darkgray ctermbg=white
    
    " key bindings (these just print things in appropriate places to save typing)
    " cmap works in escape (aka command) mode, eg, for when loading a file
    :cmap <F2> /root/code/
    " imap works in insert (aka editing) mode
    :imap <F2> printf("\n"); fflush(stdout);
    :imap <F3> 12345678901234567890
    " that last one is for counting string lengths...
    If you have any questions about using vim, or some reason why it is not the greatest piece of software of all time, post those here
    Last edited by MK27; 04-24-2009 at 09:57 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2009, 11:48 PM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  3. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM

Tags for this Thread