Hacker Newsnew | past | comments | ask | show | jobs | submit | dockerlocker's commentslogin

Is there a way how I can copy blocks of code outside the vim window to another application without also copying the line numbers?

Also is there one simple key combination to [un]comment a line or a selected block?

I found out how to do many simple operations with this ancient tool, what can be really fun if you have nothing else funny in life (too many people have no other sources of fun, really) - but I am still not convinced. Many operations that are a no-brainer in e.g. geany take serious planning and studying in vim - this is absurd.

I fear that we are wasting many potentially good programmers because they accept the primitivism and stupid limitations of vim as something "cool" and will never again in their lives be able to program a user-friendly GUI because their brain is "vimed out". Maybe that is one of the reasons why we still have so much really bad software.

Once I was totally impressed by programmers, they were the wizards of today, superbrains, uber-humans. Then I learned programming and understood how many uncreative and cognitively limited people are just repeating stuff that somebody else has told them, without ever asking. Basically the typical obey-guy, the perfect follower who never questions any order will be that kind of a good programmer, reading manuals and getting happy that he is able to reproduce - there is no creative moment here. Only very few of them are part of a creative elite that actually brings new ideas to life - most of them are totally dumb rat soldiers just following the orders. This is the reason why such ultra-primitive tools like vim still exist.


If vim causes you to write comments that go from "How to I copy and paste correctly?" to the last 3/4th of it being "Programmers are fucking stupid" ... it might not be the tool for you.


Ctrl-V to turn on rectangular visual mode, select the area you want to copy (presumably you understand to not select the line numbers), then "*y to copy it to the system clipboard. Once it's on the system clipboard, you can then paste it into another application; generally this is done with Ctrl-v or something similar, but you should check your operating system's user manual to verify this.


Normally you should be able to yank the lines you want to copy to the * register (check :registers). The * register is basically the clipboard. You can use it to copy stuff from and to Vim. It does not necessarily work under every OS, but so far in Windows and OSX it worked fine on console and GUI.

For commenting and uncommenting you can check the NerdCommenter plugin.


There are plugins for that. Check out vim-easyclip, and for comments theres vim-commentary(barebones) or nerdcommenter(loads of advanced features).


too many keystrokes, checked that.


:help :map


> Is there a way how I can copy blocks of code outside the vim window to another application without also copying the line numbers?

If you're running vim in a terminal, there is an option to add native clipboard support to your yank registers. If you use vim under OS X and have installed it with brew, it will be added automatically. To check whether your current vim installation has clipboard support, try running `vim --version | grep +clipboard`.

You might also find this to be helpful: http://vimcasts.org/blog/2013/11/getting-vim-with-clipboard-...


a good example for a stupid limitation and the enprmous waste of brian power just for a very simple thing. Have to start studying and doing real research for the most simple features. Waste!


Ideally, Vim is a tool you'll be able to use for the rest of your life, so an upfront cost in learning it is a cost that becomes small when measured against the time scale of your career.

Furthermore, Vim needs to be setup and is configurable because it existed before many computer usage patterns had been standardized that we take for granted now (e.g., Vim's cut and paste system is different than any current big name operating systems).

But the very fact that Vim pre-dates these paradigms, and continues to be used despite the extra work it requires to get past that, this very fact is what makes it more likely that you'll be able to continue using it indefinitely. I.e., Vim will survive the next paradigm shift, because it survived the last one.

If you really want to be careful about investing in learning a tool, the ones you should be careful about are the ones that have not survived a paradigm shift yet.

(Photoshop is great example of a dangerous skill investment in my opinion, Photoshop takes an extraordinary amount of muscle memory to use effectively and it hasn't yet survived a paradigm shift. Those skills look poised to become completely obselete by touch-based design tools soon, 5-10 years from now. Not saying I have an better idea, because Photoshop is still probably the best tool for doing that type of work, but just plan on throwing everything you learn away.)


Very true. I hand-compiled and memorized my own vi cheat sheet decades ago, and it has paid off very well. It's systematic, as many tutorials point out, which helps a lot.


Agreed. Vim is one of the best investments in learning I've made to date.


So fix it permanently or stop complaining?


Perhaps you should try watching some screencasts with experienced vim users editing text, the speed they can achieve and the level of precision is almost impossible in any other editor.

It is true that vim is not optimized for ease of use, especially for newcomers, and also has some problems that are considered to be solved for any decent GUI framework. But I don't see how this can affect creativity. Does carbon fiber guitar somehow magically make you more creative? Similarly, does plain old guitar made of wood hinder your creativity? I don't think so.


>Is there a way how I can copy blocks of code outside the vim window to another application without also copying the line numbers?

    set clipboard=unnamed
On Windows at least, that will make Vim use the system clipboard as its default register (the one you yank or paste from when you don't explicitly specify a register). Alternatively, you can yank and paste from the system clipboard like you would from any other register:

    "*y<movement>
    "*p


Your comment is nothing but a rant. There is no constructive criticism, only you venting your frustration and anger while calling names and lashing out at anyone within reaching distance. This is not an effective form of communication. I would suggest that you figure out a better way to deal with people if you want them to help you figure something out.

[And not all programmers use Vim or Emacs. Programmers are people, and like all people have differing opinions.]


>Is there a way how I can copy blocks of code outside the vim window to another application without also copying the line numbers?

:set nonumber


most terminals support "rectangle copy" - just keep ctrl pressed and you can select a rectangle from whatever top-left starting point - easy way to copy only content without deactivating line numbering.


    vnoremap <C-c> "+y


Just a minor nitpick, vnoremap creates a mapping for select and visual modes. You should use xnoremap as that's restricted to visual mode only.

Select mode is used by snippet engines mostly, and you don't want this mapping to affect select mode.


will update my .vimrc to reflect that, thanks! nitpick appreciated


:set nonumber removes the line numbers so you can copy without them


no, i do not want to disable line numbering. I want to avoid to copy them. I do not want to switch line numbering on off for every copy process. Absurd idea.


A better option would be to use a plugin that yanks text to the system clipboard.


You don't need a plugin for that. Just set the 'clipboard' option.


Note that you need Vim compiled with +clipboard for this to work (or +xterm_clipboard if you are using X11)


In my last round of my linux firewall comparison I liked opnsense very much:

https://opnsense.org/

not affiliated, I just liked it. However the GUI is made of many php scripts (if they did not change meanwhile) - so it would be great if many more eyes would like to take a look at the code...


They took those PHP scripts and rewrote / are rewriting them in a different PHP framework, for better, or worse.


New account...


Please add a description to your code. Yes, we can read the source, but at least a few sentences about what your work is about and what it will do will motivate many more people to take a closer look. Adding good docs values your own work!


You are right in that adding good doc adds value to my work. However, there are a lot of other things I need to do, and the value of those outweighs the value of documenting this code.

Besides, that code doesn't make sense without an example. The best example is locked behind proprietary code. Feel free to ping me if you want me to walk you through what it is about.


Ah, so you are that one guy on the internet that has so many other things to do, nice to meet you!

It is not about time. We have 24 hours every day, everyone has lots of things to do.

If I could read just one or two sentences describing what your code does, I had at least some basic information to consider if it is worth spending some time on this.

As there is nothing and you think it is a waste of time to document that code, why should I spend my time with some code that you think is a waste of time to document?

Anyway, have a nice day!


I never asked you to look at it. You choose to look at it or you don't. What social contract do you think I am violating here?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: