Vim hotkeys for pdf-tools in emacs? - pdf

Does anyone know how to get vim hotkeys inside pdf-tools for emacs?
I have found out it comes standard with spacemacs, but can't find any documentation to get the hotkeys with regular emacs. Thanks in advance if you can point me to the right direction.
PS. I am using EVIL mode, emacs 24, arch linux.

Spacemacs seems to simply bind the keys they want to the respective pdf functions:
https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Btools/pdf-tools/packages.el#L40
They obviously use their own spacemacs way of defining keybindings, but you can just copy the keys and functions and set them however you want.

Use the evil collection package, which has a special setup to use vim keybindings in pdf-tools. Although, you must take into consideration that you would have some issues with strange pdf blinking behavior. For fixing that, I mix the info I found here and here:
(add-hook 'pdf-view-mode-hook
(lambda ()
(set (make-local-variable 'evil-normal-state-cursor) (list nil))
(internal-show-cursor nil nil))
))
Nonetheless, the pdf will start blinking when you highlight part of the pdf. Hope this help!

Related

How do I disable auto-indent on Kakoune?

I don't like text editors that perform auto-indentation in my code, because of various reasons, but Kakoune seems to be hardcoded to do that? Is it possible to disable it?
I couldn't find any defined "hooks" for indent, just for autocomplete.
Just run :set global disabled_hooks .*-indent in your Kakoune window or put
set global disabled_hooks .*-indent
in your kakrc.
Found the answer at https://github.com/mawww/kakoune/wiki/How-To#disable-auto-indentation, although it wasn't immediately clear what "disabled_hooks option" meant.
It's not strictly an answer to your question, but I sometimes need to paste text into kakoune over an SSH session from Windows. In vim, I could do :set paste/:set nopaste.
In kakoune, I found I can enter insert mode with disabled hooks (see "Disabling Hooks" in https://discuss.kakoune.com/t/hooks/544) by typing in a \ first, e.g. \i. Then I paste the text without indentation fuss and can leave insert mode again. Neat!

Disable use of MacVim keyboard shortcuts

Is there any way to disable keyboard shortcuts in MacVim? I mean the shortcuts like Cmd + s for example, I want to convince myself to use things like :w, but I can't do so if I can save the file using Cmd + s, you get me?
But I of course, still want to use the GUI, so is there any way to disable these, without stoping using the MacVim GUI?
Thanks for your help. BTW I made a Google search and wasn't able to find an answer.
EDIT:
Following #ChrisJohnsen's suggestion, I have already tried the following with no success:
if has('gui_running')
macmenu File.Save key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
endif
EDIT 2:
I moved the error I'm getting over to this other question: When I try to run vim in command line I get Python errors
There is no simple way to disable all of the pre-defined Mac-style keyboard shortcuts, but you can definitely change/disable any of them. The important command is :macmenu (see :help :macmenu); it lets you set the Mac-specific properties of any Vim menu item (mostly Mac-specific keyboard shortcuts and Mac-specific actions (e.g. open/save dialog boxes, window manipulations, etc.)).
macmenu File.Save key=<nop>
macmenu File.Save\ All key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
The thing is that :macmenu commands are only effective if they are in your .gvimrc file.
If you do :e $VIMRUNTIME/menu.vim and search for macm, you will find the list of pre-defined shortcuts and actions. Copy the desired lines to you .gvimrc and replace key=<whatever> with key=<nop>. You can also wrap them in if has("gui_macvim") / endif if you need your .gvimrc to work on multiple platforms.
MacVim has only one "advantage" over plain Vim: it supports native Mac OS X shortcuts. If you don't want those shortcuts you might as well simply use plain Vim.
FWIW, when I switched from TextMate I, too, found after a while that these native shortcuts were an obstacle on my way to learning Vim. My solution was to focus my efforts on plain Vim. After a week in the terminal you should be able to completely disregard those shortcuts.
I'd advise you to take a little pause and think about doing things in a more appropriate order:
In the terminal, do $ vimtutor as many times as needed.
In the terminal again, use $ vim for simple tasks first then more complex tasks. There's a predictable productivity hit at the beginning but it will last only a few days/weeks.
Once you have reached your previous level of productivity, you can start to fly Vim full-time. At that point, using MacVim or GVim or plain $ vim should make no difference whatsoever.
Bonus points for not relying too much on plugins, other people's vimrcs or "distributions" like janus or spf13…

Keyboard shortcut to Un/Comment out code in Mathematica 7?

A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working.
I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and select Un/Comment from the menu that appears but this is too slow while coding.
I tried to access this using the menu key Menu on the keyboard but Mathematica frontend doesn't respond to or recognise this key unlike other applications, this could have allowed a key combination for commenting. Can someone else verify that this isn't unique to my machine and that the key isn't recognised by mathematica. I looked at this question and looked in the KeyEventTranslations.tr file but I don't think there is any way to create a shortcut to do this(?). Should I just live with it?
Any other suggestions?
(I have seen there is an Emacs version of mathematica, I have never tried Emacs or this Mma version and imagine that it would have this ability but would prefer not to go to the trouble and uncertainty of installing it. Also I would guess that the Wolfram Workbench could do this, but that may not be worth the investment just for this.)
You can install the shortcut in Mathematica 7.0.x if you are willing to edit the Mathematica system file MenuSetup.tr. You can find it in the same location as the KeyEventTranslations.tr file (i.e. in the installation under "SystemFiles/FrontEnd/TextResources/platform"). In MenuSetup.tr, locate the following line under the definition of the Edit menu:
MenuItem["Check &Balance", "Balance", MenuKey["B", Modifiers->{"Control", "Shift"}]],
Immediately below that line, insert the following:
MenuItem["Un/C&omment Selection", KernelExecute[FE`toggleComment[]], MenuKey["/", Modifiers->{"Command"}], MenuEvaluator -> Automatic, Method -> "Queued"],
The Un/Comment Selection command is now available under the Edit menu, with the keyboard shortcut Cmd-/ or Alt-/ depending on your platform -- just like in Mathematica 8 where this command comes pre-installed.
Please take as read the usual disclaimers about hacking the Mathematica installation files -- no warranty is offered :)
I do not know of any way to map this function to some shortcut involving the Menu key.
Shortcut Key, No Menu
The preceding steps mimic what Mathematica 8 does by installing a new menu item. If you prefer to leave the menus unchanged, then you can install the shortcut in KeyEventTranslations.tr instead. Add the following line:
Item[KeyEvent["/", Modifiers->{Command}], KernelExecute[ToExpression["FE`toggleComment[]"]], MenuEvaluator -> Automatic, Method -> "Queued"]
You'll need a comma on the end of that line if it is not the last item in the list.
Select the code and press one of the following:
Alt+/
Alt-E-O
Alt+E+O
Notes:
Tested only on Windows, using Mathematica 8.
On my non-US keyboard (ABNT Brazil), the shortcut Alt+/ doesn't work, instead I use Alt+E+O.
Here is code for your KeyEventTranslations.tr file that will comment out code. I am still working on the other half.
Item[KeyEvent["/", Modifiers -> {Command}],
FrontEndExecute[{
NotebookApply[FrontEnd`InputNotebook[],
"(*\[SelectionPlaceholder]*)"
]
}]
],
This binds it to Alt+/ as it is in Mathematica 8.

Binding function keys in carbon-emacs

While I was using the "normal" X11 emacs under Snow Leopard, my profile.el file had a line:
(global-set-key [f14] 'my_function)
However this binding does not work with carbon-emacs. What is strange is that if I execute the command "M-x global-set-key", and give it the right arguments (pressing the F14 key), it works!
Any hints?
-- Tsf
My line
(global-set-key [f14] 'my_function)
was in an auxiliary profile.el file loaded by the command
(load "profile")
in my .emacs file. When I moved it to the .emacs file itself, it worked! As a matter of fact the same happened with another definition I was having troubles with:
(setq visible-bell t)
used to disable unpleasant sounds.
-- Tsf
I'm using the normal gnu emacs for mac, probably from one of the vanilla builds..., and [f14] works fine for me... why are you using a non-standard emacs?
Granted, i'm using emacs 22, so maybe things changed, but I doubt it...

How to use multiple tabs when tagging to a function in Vim

I use ctags with my Vim and I rely heavily on C-] and C-T to tag back and froth between various functions in my project.
But if the function is in a different file, I'd like Vim to automatically open it in a new tab instead of the current tab. If I pop my tag stack using the C-T, I'd like it go back to the original tab where I pressed by C-] instead of changing the file in the current tab. I don't like to have the same file opened in multiple tabs in Vim. This is the normal behavior for most IDEs and I am wondering if there is a way to do this in Vim?
nmap <C-Enter> <C-w><C-]><C-w>T
Does this help ? You could probably figure out something similar for the way back.
Well, we need to decide what would be the wanted behaviour. We can go back to the original tab (not sure how, still investigating) but then the above given mapping is gonna open a new tab next time. So you'll end up with a lot of tabs after a while.
Or we can do <C-w>C, which will close the opened tab and take us back to the original one. I, personally, prefer this way of working (that way I don't lose my position in the file)
I go to the function I want, make my corrections there then return to the original file from which I started.
Let me know, what would you like (this didn't fit in comments so I put the answer here).
This might point you in the right direction:
http://vim.wikia.com/wiki/Open_every_buffer_in_its_own_tabpage
So, this is a feature I would like to see as well.
I'm not sure if it's possible.
What I usually do is
:tabnew
:tag somepartsoffunction*
and press tab to use globbing to easily find tag.
Sure, it's not an ideal solution, but it works most of the time.
Unfortunately, with VIM tabbing isn't totally integrated since it's a new feature since 7.0. Most people I know that use VIM weren't even aware of tabs until I told them, so with that, I have a feeling there is no way to do it right now.
(I would love to be proven wrong)