Invoking a function on a keypress in vim editor compiled with python - vim-plugin

I'm looking for a code to invoke a plugin when a key is pressed in VIM editor in Linux terminal.The plugin has to replace automatically an image path given in the file opened in Vim with that image converted into ascii. Please help me in adding key press so that the plugin works in an automated fashion???

The title of your question is
Invoking a function on a keypress in vim editor compiled with python
and I can answer that:
you can map key presses to functions using
:map Keycombo :Command^M
see vim's builting help :help map.
However, what you're asking for in the text is us to write you a complex vim script that possibly uses an external program to convert that image to ASCII art, and then to map it to a keybinding. Obviously, the key binding is the easiest part. Since we're not your paid contractors, we won't write code for you that you haven't even tried to write yourself.

Related

Pasting (with Command V) in input field on Mac

am writing feature file for UI on Mac.
I would like to enter Key.Command +'v' in an input field, using a feature file.
But I cannot see options for Key.Command in Key.java.
I see Key.SHIFT, Key.ALT, Key.CONTROL etc, but am not able to simulate the apple keyboard's Command Key. Could you please advise on that?
Thanks :)

Are there any Linux scriptable pdf readers?

I would like to make a call to a local server running a REST interface from within a pdf reader, passing the selected text as argument. The first option that came to mind was to write a simple bash script with a curl call inside, and use a script from within the pdf app to execute it.
Are there any scriptable pdf readers that would allow that? It seems that none of the most common ones (e.g. Okular, Evince, gv, xpdf) would make it possible.
Added after #DanielH comment:
I'm not asking for a method to launch arbitrary code when the a pdf file is opened. Rather, I am asking if the user can choose to launch an external app from within the pdf reader (or script).
Okular (KDE reader) has a limited form of this functionality: using KDE web shortcuts, the user can select a portion of text and then launch a browser with a predefined url that contain the text in the URL.
For instance, when an Okular user selects a word and then chooses the "Google" shortcut, Okular will launch a browser and put the following pseudo-URI in the location bar:
https://www.google.com/search?q=\{#}&ie=UTF-8
with {#} replaced by the selected text. KDE Web shortcuts are user-editable and can result in rather complex queries.
This functionality is very close to what I am after, except that the only http request that can be managed this way (as far as I know), is GET. Instead, I would need to start a POST http request, which as far as I know cannot be done from the location bar. Hence, my question about using using bash+curl.
I should have known...anything related to text on Unix? The answer is always emacs.
In particular:
the pdf-tools package can be used to read pdf files in an emacs buffer. It is much more efficient than PdfView and gives full access to annotations and all the usual emacs editing command (selecting regions, etc).
The standard emacs command shell-command-on-region can be used to launch a command with the selected region passed to it as standard input.
The command (as always in emacs) can be called interactively or from an emacs function.
All it's needed is to write a simple shell script that wraps up the needed command and passes on the input it receives.
In my case, I needed to call curl with a few parameters and a JSON string encapsulating the POST request. Iencountered a minor problem wince emacs passes the selected text (region) as standard input and not as argument, but this SX question (and #andy answer especially) helped me understand how to read piped standard input into a variable.

Is there a text editor or ide that will do this things?

Is there a text editor that will let me shade certain code blocks with specific colors so I can easily find them later? Bookmarks are great, but I also wanted to shade with the same color all code blocks which are somehow related to each other.
and
When my current text editors autocreate curly braces or parentheses for me and I type what I want in between them, are there any that let me either jump to the end of the line to put a semicolon there, or "return" to type the next line, or do I always have to use the arrow key to get out of the curly braces? Perhaps there is a shortcut I'm missing?
I think about every code editor, including Notepad++, has bookmarks. If you're looking for a more complete IDE, it probably depends on the language you're using. For .NET languages that is Visual Studio, but you probably would have known that. For PHP, Javascript and HTML/CSS, you can use Netbeans for PHP. Netbeans is also available for Java. It is a rich editor, and I think one of the best free general purpose IDE's available.
Marking pieces of code in colors is unknown to me. I've never seen an editor that supports this. You would also need a project in which to store the start and end points of these blocks, unless you would save them as comments or so in the file itself.
Visual Studio knows regions which you can define by a start tag and an end tag. You can collapse and unfold an entire region at once, making it quite easy to navigate through larger files.
But these regions are actually part of the code file, so you cannot use this for any file, because those region markers will probably make the file invalid.
I'm still wondering why any other shortcut key would be easier or more convenient than 'arrow down'..

Tool to Surround or Wrap Highlighted Text

StackOverflow's WYSIWYG has the ability to quickly surround highlighted text through keyboard shortcuts.
For example, when I push Ctrl+B on some highlighted text, it would bold the text or surround it with two stars.
I am looking for a tool that will give me this function but with "custom-input". That is... instead of bolding the word, I could surround it with a <div> tag or... in my case, I need to localize my Wordpress Plug-in, thus __("Surrounded Text").
I am currently using Notepad++ but I can't find any way to create this function.
Can this be done in Notepad++?
If it can not, I would like some suggestion for a IDE that can.
Thank you.
If you've never used an "optimized" text editor, Vim would be a sea change, but it does have a great surround.vim plugin.
Emphasize hello: ysiw<em>
<em>Hello</em> world!
Finally, let's try out visual mode.
Press a capital V (for linewise visual
mode) followed by S<p
class="important">.
<p class="important">
<em>Hello</em>> world!
</p>
Alternatively, you could probably get a fair bit of the functionality for which you are looking with an AutoHotkey script, but at best I think you'd have to do the highlight-first thing like the StackOverflow WYSIWYG editor.
Still, this would probably allow you to keep using Notepad++.
You can do this in VIM using the surround plugin

How do I keep formatting when copying from gedit into open office?

I am editing octave files in gedit, and it does a nice job highlighting them. However, when I try to copy and paste the code into Open Office, it loses all formatting. Even when I try paste > special, it still doesn't work.
Is there any way to do this without having to manually go through all my code highlighting keywords?
The free and open source editor KATE can actually export in HTML Octave's code keeping the correct syntax highlighting.
I had the same problem and I found this very usefull page: http://tohtml.com/
So you don't need to install any other editor or stuff, just copy paste to the page and let it do it.
PS: It seems like the owner likes to sell the domain, so hopefully the project will stay online, otherwise you will find other solutions google: "cpp online syntaxhighlighter"
I don't know if this can be any good, but if you open the script with the MatlabĀ® editor, then you can make copy and paste (paste > special), keeping the Octave syntax highlighting.
If you don't want to install KDE dependencies for run Kate I found a solution that could work until Scite implementation in GNU/Linux (?) haven't got the command "Copy as RTF", take a look here
So let's go:
sudo apt-get install wine synapse
wine: Windows Emulator ;)
synapse: fast application launcher
download notepad++ installer version
go to Downloads, chmod +x executable file (permissions to execute, could do graphically with properties of file, in permissions)
install it! (with default values works)
now you can run it easily with synapse:
if is launched: Ctrl+Space (or Super (windows key)+Space) and type "notepad" (if no appear, press Arrow Down and search it!)
write a text in, for example:
for i=1:3
%comment!
end
and now select it, with right button of mouse "plugin commands > copy text with syntax highlighting"
paste it!
in LibreOffice Writer: be carefull, use Ctrl+Shift+V or Edit>Paste Especial>Formated Text [RTF]
in Abiword works with Ctrl+V