Okay, so here’s the script that I’ve written so far:
function MkCheck()
put = \"✓\"
endfunction
And it works all right, but it inserts the check mark on a line all by itself. I want to insert it right at where the cursor currently is. Is there any way to get put to place the character right before (or right after) the cursor?
You can enter in insert mode, append the character and return to normal mode:
function MkCheck()
execute "normal! i✓\<ESC>"
endfunction
The :put command, like most Ex commands, is linewise: it doesn't really care about the position of the cursor in the line.
You can use the :normal command to execute a normal mode command like i✓:
function MkCheck()
normal i✓
endfunction
Related
I want to make keybinding that simply clears everything I entered after prompt and till the end. The same behavior as what Ctr+c does, but without appending ^C character to the end of current line and newline. Is it doable somehow?
You probably want Ctrlu and/or Ctrlk
Ctrl-u kills characters from your cursor to the start of entry (the prompt)
Ctrl-k kills characters from your cursor to the end of the line.
The deleted characters can be pasted (yanked) with Ctrly
Try this:
function clear_to_end
commandline (commandline --cut-at-cursor)
end
bind \cc clear_to_end
This sets the command line to the current command line, truncated at the cursor.
In IPython (5.3 in this case) pressing the RET has double meaning:
send current input to the interpreter
insert line break to the current input and let the user to modify it further
Looks like the first one is implemented only if the the cursor is in the beginning or end of the line. How can I change this behavior? For example have a separate keystroke for this purpose.
P.S. Any link to keybindings configuration in IPython would also be much appreciated.
I have a huge code and now for testing purpose I have to add that whole script into an infinite while loop is there any short way (without pressing space for each row) to add a space for indentation so the whole code is consider part of the one while loop ? Such as for example when we press ctrl +r it comments out the line
Ctrl-I/Cmd-I will automatically indent the file. Other wse you just select multiple row and use Tab/Shift-Tab to move them backwards and forwards.
For indentation is a must, however Matlab as a language does not care so it is not really a must to indent it. Additionally, you can just execute the code from the command line, say that you script or function is called Umar, then from the command line you just type while 1, Umar; end.
You can copy the code into notepad++.
Activate Column mode selection holding alt+shift and use the mouse to select the column of all the text you want to insert a space/tabulation/etc. and just insert it.
Final step is to copy back the code to matlab.
Matlab does not currently support column selection.
MATLAB has the option to select all your code, then press the right click and select smart indent button.
If you like to use shortcuts, just type the combination of Ctrl+A (select all) followed by Ctrl+I (smart indent)
Emacs has a function called indent-region and some similar functions, which insert some predefined string at the beginning of the lines within the selected region.
Instead, I want an interactive function that inserts a string given by user input at the beginning of the lines within the selected region. What emacs-lisp code can do this?
Easiest way to do this is to make use of a rectangle.
It's kind of difficult to present, but basically you can use C-x r t to insert a text on each line of a rectangle. You make a rectangle by starting with the pointer at, say, line 1, C-Space, move cursor down the amount of lines you want, and hit C-x r t following by entering the text.
Here's the documentation.
i have the following command in my .vimrc:
nmap gtb texecute "!perl /home/hermann/hi.pl ".shellescape(getline('.'), 1)
it executes a perl script and sends whichever line the cursor is over, to it.
how do i send to the script whatever is in the copy-paste buffer instead?
There is no single 'copy-paste' buffer in Vim, there is a set of named registers instead. You can get the contents of a register using getreg function - it has a single argument, register name. For example, use this to get the contents of a default yank/paste buffer:
getreg('0')
you can use the 'normal' function to paste the clipboard contents.
function MyPastingFunc()
"paste from clipboard
normal! "+p
"do more stuff
endfunction