Is there any vim feature to make this easier? I'm thinking something like ':set capsinvert' would help. It would only affect insert mode, and invert the functionality of the caps lock key. ie. normally type in capitals, but can be disabled (turn the caps lock light on) for typing string literals in normal case.
Any thoughts?
thanks,
Rob
Check :help inoremap
For e.g,
:inoremap a A
:inoremap A a
Thanks, but I can't get this to work. Am I correct in thinking that having done this, typing 'a' in insert mode should insert 'A' and vice versa?
I would need to setup 52 inoremaps and possibly functions to turn them all on or off?
Maybe it would be more easy if you write also the code in lowercase
and some hotkey to a function which selects the code (excluding string
literals) with regular expression and then make it all upercase with
'U' command.
This way you only need to press that hotkey just after (writting and)
executing the code.
...More elaborated idea could be to define BufWrite autocommand for
fortran files.
--
Joan Miquel Torres__________________________________
Linux Registered User #164872
http://www.mallorcaweb.net/joanmiquel
BULMA: http://bulma.net http://breu.bulma.net/?l2301
Ofcourse, you can put a loop instead of 52 explicit maps. Something like:
function EnableCapsMap()
let iLower=97 " Ascii value of 'a'
let iUpper=65 " Ascii value of 'A'
while iLower < 123
exe 'inoremap ' . printf("%c", iLower) . ' ' . printf("%c", iUpper)
exe 'inoremap ' . printf("%c", iUpper) . ' ' . printf("%c", iLower)
let iLower=iLower+1
let iUpper=iUpper+1
endwhile
endfunction
function DisableCapsMap()
let iLower=97 " Ascii value of 'a'
let iUpper=65 " Ascii value of 'A'
while iLower < 123
exe 'iunmap ' . printf("%c", iLower)
exe 'iunmap ' . printf("%c", iUpper)
let iLower=iLower+1
let iUpper=iUpper+1
endwhile
endfunction
Toggle the mode with
:call EnableCapsMap()
:call DisableCapsMap()
Thanks, that would be exactly what I need, except that the inoremap examples above have no effect for me. I presume it works for you. I am using vim 7.3 in a console.
Hmmm.. can't imagine why.. I checked the functions, they work for me
(in console environment as well). What is the value returned when you
do:
:echo &enc
and
:echo &tenc
and
:set
Can you check with just a single character?
Do,
:inoremap a A
and check if typing 'a' gives you 'A'
utf-8
> and
> :echo &tenc
nothing or white space, I can't tell which
> and
> :set
>
balloondelay=100 clipboard= expandtab helplang=en makeprg= number pastetoggle=<F6> ruler shell=/bin/tcsh shortmess=atoO tags= ttyfast wildmenu
ballooneval directory=. foldminlines=4 hlsearch modified paste path= scroll=53 shiftwidth=2 smartcase title ttymouse=xterm
fileencodings=ucs-bom,utf-8,default,latin1
wildmode=longest:full
*ahh, it is the paste mode!*
> Can you check with just a single character?
> Do,
> :inoremap a A
> and check if typing 'a' gives you 'A'
ok, with paste mode turned off (otherwise not)
thanks for your help.
I have a sort of similar case: often, completion gives me a word with
first letter capitalized, while I need all lower-case (e.g. for a
variable). I have an insert-mode mapping that lowercases first letter of
that word and returns to insert mode:
inoremap <m-0> <esc>b~ea
You can use for example gUe command to uppercase to the end of a word.
That way you only need a single keystroke per word, which I think is
better and easier than switch to upper, type, then switch back. You also
won't have a problem with forgetting that you're in uppercase and typing
something that should be lowercase. -ak
like (I don't know what are the keywords in fortran):
:iabbr function FUNCTION
That way, you do not have to bother about case at all, vim will
correct it for you. Having a look at the fortran syntax file might
help in getting a good list of keywords.