You can use kill-whole-line to kill the entire line point is on. Position of point does not matter. This command is bound to C-S-DEL by default.
You can also instruct kill-line (bound to C-k) to kill the entire line by setting the variable kill-whole-line to a non-nil value:
(setq kill-whole-line t)
Note that point has to be at the beginning of the line ...
You need to customize save-interprogram-paste-before-kill to t. This will push your clipboard onto the killring in case you kill something in emacs before pasting the clipboard. A related customization is yank-pop-change-selection which pushes your current yank in emacs onto the clipboard. For both of these to work, you need x-select-enable-clipboard (...
Copy from Emacs to OS X clipboard:
select region then M-| pbcopy RET
Paste from OS X clipboard to Emacs:
C-u M-| pbpaste RET (replaces current region if it exists)
M-| runs shell-command-on-region, which as the name implies pipes the current region to a shell command. C-u M-| does the same thing, but replaces the current region with the ...
There is no bug here. Since I was also annoyed with this behavior, I just read Evil code to find out why this is happening. So, here is a straight copy/paste of the well-commented one-liner from my Emacs configuration that fixes this issue:
;; Imagine the following scenario. One wants to paste some previously copied
;; (from application other than Emacs) ...
The solution I've found for myself is to use prefix arguments.
For me, killing half a line is a useful feature, but I want an easier
way of killing entire lines too. So I made it so that
murders everything in sight when given a prefix argument.
(defmacro bol-with-prefix (function)
"Define a new function which calls FUNCTION.
Except it ...
There's a package called whole-line-or-region which advises various built-in commands so that they act on the current line if no region is active, so M-w will copy the current line, and C-w will kill it, for example. I've been using the package for years, and find it indispensable.
Additionally, this package makes it so that a numeric prefix will indicate ...
(buffer-substring (line-beginning-position) (line-end-position))
As Tobias noted, this also copies properties of text. If you want to avoid that, you might want to go with buffer-substring-no-properties instead:
(buffer-substring-no-properties (line-beginning-position) (line-end-position))
is it feasible to make one?
Since this is emacs, yes.
My approach is to use a 3rd party tools that can take HTML and convert to plain text or even directly to Org format. I think this is an ugly hack, and there may be better ways to do this, but it looks like it works for my test cases.
(defun kdm/html2org-clipboard ()
"Convert clipboard contents from ...
This is not an answer for orthodox emacs. If, however, you're willing to blaspheme with evil's modal editing, you can:
dd for kill line
cc for copy line
Both can be prefixed by the number of lines to kill/copy (eg, 4cc will copy the next 4 lines).
If you use Emacs "the normal way" (i.e. as a GUI application), then it should already do that by default. If you use Emacs inside a terminal emulator, then indeed it doesn't know how to do that by default, but you can install the xclip package from GNU ELPA and then enable the xclip-mode which teaches Emacs how to do that both for GNU/Linux and for OSX.
Use function directory-files, for which C-h f tells you:
directory-files is a built-in function in `C source code'.
(directory-files DIRECTORY &optional FULL MATCH NOSORT)
Return a list of names of files in DIRECTORY.
There are three optional arguments:
If FULL is non-nil, return absolute file names. Otherwise return names
that are relative to the ...
C-y does work, but you can also paste into the minibuffer from the default register with, e.g., M-mre" or M-mrereturn--or by searching the contents of all registers: for example M-mre text copied a while ago.
M-m is the default dotspacemacs-emacs-leader-key: it's similar to SPC (which is the default dotspacemacs-leader-key), but the former is available ...
My crystal ball tells me you're using Emacs-24.5, which indeed had this limitation. This has been fixed in Emacs-25 where rectangle-mark-mode has been improved so you can move the cursor past the "end" of a line (and where you can use C-x C-x to go to another corner of the rectangle as well).
Sounds like you are being bitten by the fact that one command is bound to mouse-2, another command is bound to down-mouse-2, and the two commands do not play well together.
Do C-h k and then click mouse-2 on text (e.g. mistaake). The help should tell you what mouse-2 and down-mouse-2 are bound to.
If I'm right in my guess, you can try doing one of these ...
If you just need this behavior for mouse selections, you can use the built-in setting mouse-drag-copy-region:
(setq mouse-drag-copy-region t)
If non-nil, copy to kill-ring upon mouse adjustments of the region.
The selection can be copied automatically if the OS supports primary selection by setting the below variable.
(setq x-select-enable-primary t)
From C-h v x-select-enable-primary, you get,
Non-nil means cutting and pasting uses the primary selection
The existence of a primary selection depends on the underlying GUI you use.
E.g. it doesn't exist ...
I use the following for this:
(defun my-copy-simple (beg end)
"Save the current region to the kill ring after stripping extra whitespace and new lines"
(copy-region-as-kill beg end)
(while (looking-at "[ \t\n]")
You can use the external utilities xsel or xclip (they have mostly the same features, I'll use xsel in this answer) to copy data from or to the X clipboard. To copy to the clipboard, pass the desired content on standard input. When pasting from the clipboard, the content is written to standard output.
To copy the selection to the X clipboard, use M-| xsel -...
1) How shall I avoid creating a text file with mixed encodings when copying its different parts from different sources into an editor such as emacs?
Irrespective of the source, you can always set the encoding of a buffer by setting the variable buffer-file-coding-system. An easy way to do this is via the keybinding C-x RET f which prompts you for a file ...
When I copy the text from the source to the emacs buffer ...
What you copy depends upon the application you are copying from. Some applications release UTF-8 encoded strings while others use different formats. Emacs uses the variable selection-coding-system to determine whether to decide the encoding from the data or presume a particular encoding. See the ...
Starting at the beginning of line 4 (ESC 4 ESC g g or M-4 M-g M-g to go there), C-3 C-k C-2 C-n C-y (or ESC 3 C-k down down C-y if you don't like holding modifiers down) will do this.
If you don't want to do the arithmetic in your head, but instead select lines visually, then
Move to the beginning of the zone to move
C-SPC to set the mark
Move down to the ...
The package https://github.com/Lindydancer/highlight2clipboard does exactly what you asked for. It use htmlize to create a HTML version of the text which it adds as an alternative paste text. (Note: This is a non-trivial operation which requires interfacing with the clipboard. This is operating system specific, currently OS X and MS-Windows are supported.)
As you have noticed, you can yank the password when Magit is reading
it in the minibuffer (this works pretty much always when user input is
read in the minibuffer for whatever purpose). So the sequence is more
P P RET
This might or might not cache the password, depending on various
settings. First you need to tell Git to cache the ...
These are just point and mark right after the yank command. Just see the doc for yank or yank-pop. If you want to conserve these positions you could advice yank. Make sure that you save these values as markers or in buffer-local variables!
One more thing: If you want to see these values just once you can call M-: (mark) and M-: (point) right after the yank ...
Besides @itsjeyd answer, may I suggest those two functions?
(defun xah-copy-line-or-region ()
"Copy current line, or text selection.
When `universal-argument' is called first, copy whole buffer (but respect `narrow-to-region')."
(let (p1 p2)
(if (null current-prefix-arg)
(progn (if (use-region-p)
Do not worry about the kill ring ("clipboard") being overwritten: you can recover previous kill ring entries by typing C-y M-y (repeat M-y as many times as you need). See Section 12.2.2 of the Emacs manual for more.
If you really want to disable M-w when the region is inactive ("not highlighted"), which I do not recommend, you can probably do something ...
After yanking with C-y, press M-y to run the command yank-pop. Repeated presses will cycle through the kill-ring.
For example, if you have:
and you kill Hello and world (you have , ! left), then go to the next line and hit:
SPCC-y Hello Hello
C--M-y Hello world