ViEmu |
ViEmu forumsEverything about ViEmu: news, support, general discussion... |
You are not logged in. |
Someone suggested I start a "Sticky" topic with this issue. I thought it was a great idea!
I only use a couple of mappings in my .viemurc, but I wouldn't want to do without them:
cnoremap <c-n> <down>
cnoremap <c-p> <up>
This makes Ctrl-N and Ctrl-P act as arrows to move around history in the command line, that is, when typing a '/' or '?' search or a ':' ex command.
I guess I'm not much for customizing my apps. Incidentally, I think that's one of the reasons I love vi/vim editing so much: it's a huge amount of power out-of-the-box!
My favorite usage tricks are described in my already well-known "Why vi/vim" article:
"Why, oh WHY, do those nutheads use vi?" -- http://www.viemu.com/a-why-vi-vim.html
Thanks for sharing your tricks!
-- Jon
Offline
Hi I am new user of ViEmu. What is .viemurc and where is this found?
I am facing one problem while I search using '/', when I want to paste
the search command using Ctrl-P it is getting pasted in text area.
Any trick to fix this?
Thanks,
Madhan
Offline
Here are my favorites:
nnoremap <a-n> :noh<return>
nnoremap <c-t> xph
nnoremap <a-\> zR
nnoremap <c-a-\> zM
1. clear the search highlight by pressing Alt-N.
2. emulate vi's Ctrl-T operation by toggling the character under the cursor with the next
3. Alt-\ to expand all collapsed regions and other areas
4. Ctrl-Alt-\ to collapse all regions and other areas
I don't use #4 very often but have it mainly to balance having #3
#1 I use many times a day to clear that lovely yellow search term highlighting when I've found what I was looking for.
Offline
I love the <a-n> one! I'm adding it to my _viemurc and my _vimrc right now. I had tried mapping the backslash (<\>) to :noh, but it seemed too much. This <a-n> seems great: it doesn't clash with anything in vim or VS, it's on the same key as <n> and <N>, which are related to find...
The other ones aren't very useful for me, but I'm sure others will appreciate it.
Thanks so much!!
- Jon
Offline
I map my escape key in normal mode to do the :noh as well as an escape (nnoremap <esc> :noh<cr><esc>). It somehow seems logical to me to clear the highlight with escape.
Offline
I have to admit, although I keep Alt-N around to clear the highlighting, I don't use it any more. Attaching it to the Escape key is much more intuitive. I hadn't thought of redefining Escape to enhance it's functionality without losing Escape. What a concept!
Offline
Tomlu, apologies for not noticing the above properly until Tomservo3k responded yesterday. That is the most amazing mapping ever! I don't know how it isn't more popular. I just tweeted it, people are RTing it, and I'm going to blog about it.
One million thanks!!
Offline
I like these ones:
vmap <TAB> >gv
vmap <S-TAB> <gv
Use TAB to indent and shift-TAB to unindent the visually selected lines.
If a block is selected Vim indents/unindents what is right of the start of
the block. (Unfortunately) ViEmu behaves here differently, it moves also
the complete lines.
Offline
This will take a bit to explain...
I'll define several procedures, etc, in a file like:
/* {
ALTER -- CREATE
PROCEDURE fubar
AS
BEGIN
RAISERROR( 'Hi', 0,1);
END;
} */
Then, with the cursor where-ever you happen to be editing inside the code, you can do "vi{<F5>" to recompile.
Unfortunately, it appears that you can't get ViEmu to pass the <F5> to SStudio, so I am using the open-source program AutoHotKey to create an <a-F5> hotkey to perform the above. I also define <s-F5> to select the current line from column 4 (assuming it is behind a '-- ') to the end of the line and execute it.
Offline
Thanks pDaleC, that looks like a great idea. ViEmu indeed can't originate new keypresses except for its own engine (faking user input in Windows is highly non-trivial). Fortunately AutoHotKey seems to be a great tool and allows that kind of thing!
In any case, this goes on to show how many useful things can be added to modern IDEs and similar environments... there is a lot of stuff to be made yet.
Offline
I use this one to convert c# members to properties
nmap <C-P> yyp:s/;/ {/<CR>k^diwiprivate<Escape>0f;bi_<Escape>yiwjoget { return <Escape>pa; }<Escape>oset { <Escape>pa = value; }<Escape>o}<Escape>==o<Escape>:noh<CR>
using <c-p> on a line like this:
public bool active;
will convert to:
private bool _active;
public bool active {
get { return _active; }
set { _active = value; }
}real time saver on older .net 2.0 projects
Offline
Princker, thanks for sharing, it looks like an interesting macro! I don't do much C#, but this kind of thing could even be useful to add to Codekana for non-vi(m)ers.
Happy holidays!
-- Jon
Offline
I don't have the code for it here now, but I created a mapping that indents/outdents the text within curly-braces. Very similar to the one you mentioned as "Example #5: indenting a block" on http://www.viemu.com/a-why-vi-vim.html except that it *doesn't* move the braces themselves. Since the braces are most often best considered as part of the *surrounding* block (particularly on function bodies, where they're already at the far left column), I find this behavior preferable.
Offline
Hi Jon,
Somehow, I could not find my .viemurc under C:\Program Files\ViEmu
? Could you help ?
Offline
Chan, it could be in your user directory too (see %HOMEDRIVE% and %HOMEPATH% environment variables). Regards, - Jon
Offline
Hi Jon,
Sorry for my stupid question, but I don't really understand what are %HOMEDRIVE% and %HOMEPATH% environment variables "folder". And I tried to create a new file and named it .viemurc but Windows 7 does not let me to do so. It told me that I need to specify a file name. So I think .viemurc must be a special file right? Can you give me some more hints? Thanks a lot for your quick support ![]()
Offline
Chan,
You home folder is typically one of these two:
C:\Documents and Settings\{username}
C:\Users\{username}
The first one in Windows XP, then second one in Vista or later.
The infallible way to tell is to launch a command window and type the following commands:
echo %HOMEDRIVE%
echo %HOMEPATH%
This way, you should know the path where to get it.
Apart from this, the Windows shell indeed causes trouble with filenames starting with a dot. That is why ViEmu allows the file to be called "_viemu" with an underscore. Try doing that, it should work.
[[EDIT: there is a mistake above, it should say "_viemurc" instead of "_viemu"]]
Offline
Hi Jon,
Thanks again, but I couldn't find _viemu in either those directory. I'm running Windows Server 2003 at work and I could not find it either? So is it possible for me to create one? Can you post the content of your _viemu file if you have a chance?
Thanks,
Edit :
Just create on file named "_viemurc" in ViEmu folder, it worked
! So simple
!
Thanks Jon !
Last edited by chan_nguyen (2010-07-08 16:03:04)
Offline
Sorry Chan, I wrote it wrong, it's _viemurc of course as you found out!
Offline
Hi Jon,
I started using viEmu under Visual Studio 2010 lately, but seem like _viemurc did not work for VS2010. I edited the _vieumrc already, but when I launched VS2010, it did not load the key that I mapped. Can you help me out?
Thanks,
Offline
Chan, it should work. Make sure it is in your user folder (%HOMEDRIVE% and %HOMEPATH%), and that if you go with the CMD console, a DIR shows it there (that it's not a "shadow" file). Please follow up with us if this does not help.
Offline
Thanks John,
Got it work perfectly
!
Offline
Hi Jon,
I have some problems with my 'copy' and 'paste' key bindings. Whenever I copy from any other source I have to open View -> Paste. I just want to know which key is for Ctrl-C and which key is for Ctrl-C. In Linux I used +gP and +y for paste and copy. I wonder is there a similar way in Visual Studio?
Thanks,
Offline