Sponsored Content
Full Discussion: Need some help with vim
Top Forums UNIX for Dummies Questions & Answers Need some help with vim Post 302162450 by Legend986 on Tuesday 29th of January 2008 03:41:30 AM
Old 01-29-2008
Actually I could get this for a java file:

Code:
autocmd Filetype java imap ( ()<left>
function! My_BracketComplete()
    let char = strpart(getline('.'), col('.')-1, 1)
    if (char == ")")
        return "\<Right>"
    else
        return ")"
    endif
endfunction
autocmd FileType java inoremap ) <C-R>=My_BracketComplete()<CR>

autocmd Filetype java imap { {}<left><cr><cr><up><tab>
function! My_BraceComplete()
    let char = strpart(getline('.'), col('.')-1, 1)
    if (char == ")")
        return "\<Right>"
    else
        return "}"
    endif
endfunction
autocmd FileType java inoremap } <C-R>=My_BraceComplete()<CR>

But I when I modify it to use a cc file, it doesn't work

Code:
autocmd Filetype cc imap ( ()<left>
function! My_BracketComplete()
    let char = strpart(getline('.'), col('.')-1, 1)
    if (char == ")")
        return "\<Right>"
    else
        return ")"
    endif
endfunction
autocmd FileType cc inoremap ) <C-R>=My_BracketComplete()<CR>

autocmd Filetype cc imap { {}<left><cr><cr><up><tab>
function! My_BraceComplete()
    let char = strpart(getline('.'), col('.')-1, 1)
    if (char == ")")
        return "\<Right>"
    else
        return "}"
    endif
endfunction
autocmd FileType cc inoremap } <C-R>=My_BraceComplete()<CR>

 

10 More Discussions You Might Find Interesting

1. Solaris

Vim 7.0

I want to install VIM 7.0 from sunfreeware.com onto a server. The security guys are giving me a hard time because they found this security vulnerability. http://xforce.iss.net/xforce/xfdb/6259 This vulnerability came out in 2001, and it looks like it was mostly for linux, but I cant be... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

2. UNIX for Dummies Questions & Answers

how to configure VIM ?

hi today i was working on AIX server and faced many problem while working with VIM. some issues were like configuring VIM where can i configure vim such as ruler was not displayed by default no hlsearch as well as when you try to execute prveious RE with up arrow its not working how to configure... (1 Reply)
Discussion started by: zedex
1 Replies

3. Shell Programming and Scripting

Vim color

How can I change the color in Vim for *sh scripts for words which in brackets "words". In another words for string variables. As I know id depends on /usr/share/vim/vim71/syntax/sh.vim. But I can not find where exactly. (1 Reply)
Discussion started by: mirusnet
1 Replies

4. UNIX for Advanced & Expert Users

About Vim

Hello, what is the maximum size of a file that we can open using vim. (3 Replies)
Discussion started by: nagalenoj
3 Replies

5. UNIX and Linux Applications

Help with Vim

How do I use compilers and syntax highlighting in (g)Vim? Specifically, I need a Common Lisp compiler and a C++ compiler. Thanks in advance! (Note: Disregard my other topic.) (1 Reply)
Discussion started by: led3234
1 Replies

6. Shell Programming and Scripting

Vim - Question

Hi, I'm not sure whether this is the right place for my question. For scripting I use very often Vim because it's almost available on all unix stations. Sometimes it would be very helpful to exchange text inside Vim with other programs and the other way round! For example I want to copy... (4 Replies)
Discussion started by: climber
4 Replies

7. UNIX for Advanced & Expert Users

vim

Does anyone know the fast way to go to tab/2 distance in vim. I mean set four spaces. (1 Reply)
Discussion started by: mirusnet
1 Replies

8. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

9. Linux

VI/VIM ERROR ^Z

Dear Unix user, I'm using putty 0.60 (on Windows Vista) to connect by ssh protocol to other Linux computer. I have a problem with VI/VIM. When I key button "n" or "b", it returns me n^Z or b^Z. What could the problem be?! Thanx a lot, Maria Elena (0 Replies)
Discussion started by: mesana
0 Replies

10. UNIX for Advanced & Expert Users

Vim :f

Can someone please tell me what this does? :f word I thought that was the way to save files with a different name but after a quick google search I saw it was like this. :w filename (4 Replies)
Discussion started by: cokedude
4 Replies
VIMTUTOR(1)						      General Commands Manual						       VIMTUTOR(1)

NAME
vimtutor - the Vim tutor SYNOPSIS
vimtutor [-g] [language] DESCRIPTION
Vimtutor starts the Vim tutor. It copies the tutor file first, so that it can be modified without changing the original file. The Vimtutor is useful for people that want to learn their first Vim commands. The optional argument -g starts vimtutor with gvim rather than vim, if the GUI version of vim is available, or falls back to Vim if gvim is not found. The optional [language] argument is the two-letter name of a language, like "it" or "es". If the [language] argument is missing, the lan- guage of the current locale will be used. If a tutor in this language is available, it will be used. Otherwise the English version will be used. Vim is always started in Vi compatible mode. FILES
/usr/local/lib/vim/tutor/tutor[.language] The Vimtutor text file(s). /usr/local/lib/vim/tutor/tutor.vim The Vim script used to copy the Vimtutor text file. AUTHOR
The Vimtutor was originally written for Vi by Michael C. Pierce and Robert K. Ware, Colorado School of Mines using ideas supplied by Charles Smith, Colorado State University. E-mail: bware@mines.colorado.edu. It was modified for Vim by Bram Moolenaar. For the names of the translators see the tutor files. SEE ALSO
vim(1) 2001 April 2 VIMTUTOR(1)
All times are GMT -4. The time now is 07:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy